/// <summary> /// 链接到内容页 /// </summary> /// <param name="_contentid">内容ID</param> /// <param name="_initialize">是否初始化</param> /// <returns></returns> public string Go2View(string _contentid) { SiteGroupCms.Dal.ArticleDal articledal = new ArticleDal(); SiteGroupCms.Entity.Article article = articledal.GetEntity(_contentid); SiteGroupCms.Entity.Normal_Channel _Channel = new SiteGroupCms.Dal.Normal_ChannelDAL().GetEntity(article.Catalogid.ToString()); return(ModuleCommand.GetContentLink(_contentid)); }
/// <summary> /// 得到内容页地址 /// </summary> /// <param name="_contentid"></param> /// <param name="_truefile"></param> /// <returns></returns> public string GetContentLink(string _contentid) { SiteGroupCms.Dal.Normal_ChannelDAL _ChannelDal = new Normal_ChannelDAL(); SiteGroupCms.Dal.ArticleDal articledal = new ArticleDal(); SiteGroupCms.Entity.Article article = articledal.GetEntity(_contentid); if (article.Yyarticleid.ToString() != "" && article.Yyarticleid != 0)//如果引用文章 { _contentid = article.Yyarticleid.ToString(); } article = articledal.GetEntity(_contentid); //重新取引用的文章 if (article.Linkurl != "" && article.Linkurl != null) //如果是连接文章 // return article.Linkurl; //这个直接得到连接地址 { return("/ajaxhandler/Gethits.aspx?articleid=" + article.Id); //得到可以统计点击次数的连接地址 } SiteGroupCms.Entity.Normal_Channel _Channel = _ChannelDal.GetEntity(article.Catalogid.ToString()); site = (SiteGroupCms.Entity.Site)HttpContext.Current.Session["site"]; string qianstr = "/sites/" + site.Location + "/pub"; string centerstr = ""; //检查对应的文件夹是否存在,若不存在则创建,若存在则以id为标题生成 while (_Channel.Father != 0)//不为跟节点就继续往上走 { centerstr = "/" + _Channel.Dirname + centerstr; _Channel = _ChannelDal.GetEntity(_Channel.Father.ToString()); } centerstr = "/" + _Channel.Dirname + centerstr + "/"; string title = article.Addtime.Year.ToString() + article.Addtime.Month.ToString() + article.Addtime.Day.ToString() + _contentid; return(qianstr + centerstr + title + ".html"); }
protected void loadarticle(string id) { SiteGroupCms.Dal.ArticleDal artdal = new SiteGroupCms.Dal.ArticleDal(); SiteGroupCms.Entity.Article art = new SiteGroupCms.Entity.Article(); art = artdal.GetEntity(id); SiteGroupCms.Dal.ArticlepicDal artpicdal = new SiteGroupCms.Dal.ArticlepicDal(); SiteGroupCms.Dal.ArticleattsDal artattsdal = new SiteGroupCms.Dal.ArticleattsDal(); SiteGroupCms.Entity.Articlepic artpic = new SiteGroupCms.Entity.Articlepic(); SiteGroupCms.Entity.Articleatts artatts = new SiteGroupCms.Entity.Articleatts(); List <SiteGroupCms.Entity.Articlepic> piclist = artpicdal.getEntityList(id); List <SiteGroupCms.Entity.Articleatts> attslists = artattsdal.getEntityList(id); //获取imglist和imgtitlelist string imglist = ""; string imgtitlelist = ""; string attslist = ""; string attstitlelist = ""; for (int i = 0; i < piclist.Count; i++) { imglist += piclist[i].Url + ","; imgtitlelist += piclist[i].Title + ","; } for (int i = 0; i < attslists.Count; i++) { attslist += attslists[i].Url + ","; attstitlelist += attslists[i].Title + ","; } string _response = ""; if (art != null) { string isppt = art.Isppt == 1 ? "true" : "false"; string isrecommend = art.Isrecommend == 1 ? "true" : "false"; string isroll = art.Isroll == 1 ? "true" : "false"; string isshart = art.Isshare == 1 ? "true" : "false"; _response += "{\"IsError\":false,\"Message\":\"加载成功\",\"Data\":{"; _response += "\"artid\":" + art.Id + ",\"catalogid\":" + art.Catalogid + ",\"title\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Title); _response += ",\"abstract\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Abstract) + ",\"addtime\":\"" + art.Addtime.ToString("yyyy-MM-dd") + "\",\"color\":\"" + art.Color + "\""; _response += ",\"isppt\":" + isppt + ",\"isrecommend\":" + isrecommend + ",\"isshare\":" + isshart + ",\" isroll\":" + isroll; _response += ",\"keywords\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Keywords) + ",\"linkurl\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Linkurl) + ",\"source\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Source) + ",\"subtitle\":" + SiteGroupCms.Utils.fastJSON.JSON.WriteString(art.Subtitle); _response += ",\"imglist\":\"" + imglist + "\",\"imgtitlelist\":\"" + imgtitlelist + "\""; _response += ",\"attslist\":\"" + attslist + "\",\"attstitlelist\":\"" + attstitlelist + "\",\"clickcount\":" + art.Clickcount; _response += "}}"; } Response.Write(_response); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Admin_Load("1", "json"); if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { id = Request.QueryString["id"]; SiteGroupCms.Dal.ArticleDal articledal = new SiteGroupCms.Dal.ArticleDal(); SiteGroupCms.Entity.Article article = articledal.GetEntity(id); if (article != null) { content2.Value = article.Content; } } } }
/// <summary> /// 更新文章 /// </summary> /// <param name="object">对象</param> public bool UpdateArticle(SiteGroupCms.Entity.Article obj) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.ConditionExpress = "id=@id"; _doh.AddConditionParameter("@id", obj.Id); _doh.AddFieldItem("title", obj.Title); _doh.AddFieldItem("subtitle", obj.Subtitle); _doh.AddFieldItem("keywords", obj.Keywords); _doh.AddFieldItem("abstract", obj.Abstract); _doh.AddFieldItem("siteid", obj.Siteid); _doh.AddFieldItem("catalogid", obj.Catalogid); _doh.AddFieldItem("linkurl", obj.Linkurl); // _doh.AddFieldItem("author",obj.Author); _doh.AddFieldItem("passuserid", obj.Passuserid); _doh.AddFieldItem("source", obj.Source); if (obj.Addtime.ToString() != "0001/1/1 0:00:00") { _doh.AddFieldItem("addtime", obj.Addtime.ToString()); } // if (obj.PassTime.ToString() != "0001/1/1 0:00:00") // _doh.AddFieldItem("passtime", obj.PassTime.ToString()); // if (obj.Publishtime.ToString() != "0001/1/1 0:00:00") // _doh.AddFieldItem("publishtime", obj.Publishtime.ToString()); _doh.AddFieldItem("ispassed", obj.Ispass); _doh.AddFieldItem("isdel", obj.IsDel); _doh.AddFieldItem("isrecommend", obj.Isrecommend); _doh.AddFieldItem("isppt", obj.Isppt); _doh.AddFieldItem("isroll", obj.Isroll); _doh.AddFieldItem("ispublish", obj.Ispublish); _doh.AddFieldItem("isshare", obj.Isshare); _doh.AddFieldItem("templates", obj.Templateid); _doh.AddFieldItem("color", obj.Color); _doh.AddFieldItem("content", obj.Content); _doh.AddFieldItem("clickcount", obj.Clickcount); _doh.AddFieldItem("yyarticleid", obj.Yyarticleid); int _update = _doh.Update("yy_articleinfo"); return(_update == 1); } }
/// <summary> /// 删除内容页 /// </summary> /// <param name="_ChannelId"></param> /// <param name="_ContentId"></param> public void DeleteContent(string _ContentId) { SiteGroupCms.Dal.ArticleDal articledal = new ArticleDal(); SiteGroupCms.Entity.Article article = articledal.GetEntity(_ContentId); SiteGroupCms.Entity.Normal_Channel _Channel = new SiteGroupCms.Dal.Normal_ChannelDAL().GetEntity(article.Catalogid.ToString()); using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.ConditionExpress = "[Id]=" + _ContentId; object[] _value = _doh.GetFields("yy_articleinfo", "AddDate,FirstPage"); string _date = _value[0].ToString(); string _firstpage = _value[1].ToString(); if (_firstpage.Length > 0) { string _folderName = String.Format("/detail_{0}_{1}/{2}", DateTime.Parse(_date).ToString("yyyy"), DateTime.Parse(_date).ToString("MM"), DateTime.Parse(_date).ToString("dd") ); if (System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(site.Location + _Channel.Dirname + _folderName))) { string htmFile = HttpContext.Current.Server.MapPath(Go2View(_ContentId)); if (System.IO.File.Exists(htmFile)) { System.IO.File.Delete(htmFile); } string[] htmFiles = System.IO.Directory.GetFiles(HttpContext.Current.Server.MapPath(site.Location + _Channel.Dirname + _folderName), _ContentId + "_*" + "htm"); foreach (string fileName in htmFiles) { if (System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName); } } } _doh.Reset(); _doh.SqlCmd = "UPDATE [jcms_module_" + _Channel.Type + "] SET [FirstPage]='' WHERE [ChannelId]=" + article.Catalogid + " AND [Id]=" + _ContentId; _doh.ExecuteSqlNonQuery(); } } }
/// <summary> /// 获得单页内容的单条记录实体 /// </summary> /// <param name="_id"></param> public SiteGroupCms.Entity.Article GetEntity(string _id) { SiteGroupCms.Entity.Article article = new SiteGroupCms.Entity.Article(); using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [yy_articleinfo] WHERE [Id]=" + _id; DataTable dt = _doh.GetDataTable(); if (dt.Rows.Count > 0) { article.Id = Str2Int(_id); article.Title = dt.Rows[0]["title"].ToString(); article.Subtitle = dt.Rows[0]["subtitle"].ToString(); article.Keywords = dt.Rows[0]["keywords"].ToString(); article.Abstract = dt.Rows[0]["abstract"].ToString(); article.Siteid = Str2Int(dt.Rows[0]["siteid"].ToString()); article.Catalogid = Str2Int(dt.Rows[0]["catalogid"].ToString()); article.Linkurl = dt.Rows[0]["linkurl"].ToString(); article.Author = dt.Rows[0]["author"].ToString(); article.Passuserid = Str2Int(dt.Rows[0]["passuserid"].ToString()); article.Source = dt.Rows[0]["source"].ToString(); article.Addtime = Validator.StrToDate(dt.Rows[0]["addtime"].ToString(), DateTime.Now); article.PassTime = Validator.StrToDate(dt.Rows[0]["passtime"].ToString(), DateTime.Now); article.Publishtime = Validator.StrToDate(dt.Rows[0]["publishtime"].ToString(), DateTime.Now); article.Ispass = Str2Int(dt.Rows[0]["ispassed"].ToString()); article.IsDel = Str2Int(dt.Rows[0]["isdel"].ToString()); article.Isrecommend = Str2Int(dt.Rows[0]["isrecommend"].ToString()); article.Isppt = Str2Int(dt.Rows[0]["isppt"].ToString()); article.Isroll = Str2Int(dt.Rows[0]["isroll"].ToString()); article.Ispublish = Str2Int(dt.Rows[0]["ispublish"].ToString()); article.Isshare = Str2Int(dt.Rows[0]["isshare"].ToString()); article.Templateid = Str2Int(dt.Rows[0]["templates"].ToString()); article.Color = dt.Rows[0]["color"].ToString(); article.Content = dt.Rows[0]["content"].ToString(); article.Clickcount = Str2Int(dt.Rows[0]["clickcount"].ToString()); article.Yyarticleid = Str2Int(dt.Rows[0]["yyarticleid"].ToString()); } return(article); } }
public virtual string GetContent(string _ContentId) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [yy_articleinfo] WHERE [Id]=" + _ContentId; DataTable dtSearch = _doh.GetDataTable(); if (dtSearch.Rows.Count == 0) { dtSearch.Clear(); dtSearch.Dispose(); return("内容错误"); } SiteGroupCms.Dal.ArticleDal articledal = new ArticleDal(); SiteGroupCms.Entity.Article article = articledal.GetEntity(_ContentId); SiteGroupCms.Entity.Site site = (SiteGroupCms.Entity.Site)HttpContext.Current.Session["site"]; TemplateEngineDAL te = new TemplateEngineDAL(article.Catalogid.ToString()); string PageStr = string.Empty; _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [yy_articleinfo] WHERE [Id]=" + _ContentId; DataTable dtContent = _doh.GetDataTable(); string ChannelId = dtContent.Rows[0]["catalogid"].ToString(); te.PageNav = Go2Site() + " »" + Go2Channel(ChannelId, 0); te.PageTitle = site.WebTitle + "--" + dtContent.Rows[0]["title"].ToString(); te.PageKeywords = dtContent.Rows[0]["keywords"].ToString(); te.PageDescription = dtContent.Rows[0]["abstract"].ToString(); p__GetChannel_Article(te, dtContent, ref PageStr); //提取出模板的内容 te.ReplacePublicTag(ref PageStr); //包含include解析 siteconfig解析 已经注释掉了 replaceTag_ChannelLoop解析 //te.ReplaceChannelTag(ref PageStr, ChannelId); // PageStr = PageStr.Replace("{$channelid}",ChannelId); te.replaceTag_ChannelLoop(ref PageStr, ChannelId); //替换频道循环标签 te.ReplaceContentTag(ref PageStr, _ContentId); //解释单片文档的所有标签 te.ReplaceContentLoopTag(ref PageStr); // te.ReplaceChannelTag(ref PageStr, ChannelId); //替换 te.ExcuteLastHTML(ref PageStr); //替换注释标签 PageStr = SiteGroupCms.Utils.Strings.UBB2HTML(PageStr); //替换ubb标签 return(PageStr.Replace("{$Content}", dtContent.Rows[0]["content"].ToString())); // .Replace("{$_getPageBar()}", getPageBar(1, "html", 7, ContentList.Count - 1, 1, _CurrentPage, Go2View(true, _ChannelId, _ContentId, false), Go2View(true, _ChannelId, _ContentId, false), Go2View((true), _ChannelId, _ContentId, false), 0)); } }
public void updatestate(string str) { bool sucess = false; for (int i = 0; i < id.Split(',').Length; i++) { switch (str) { case "delarticle": //放入回收站和修改发布状态为未发布,并且重新生成频道标签和首页标签 if (articledal.huihouById(id.Split(',')[i], 1)) { articledal.publish(id.Split(',')[i], 0); SiteGroupCms.Entity.Article article = articledal.GetEntity(id.Split(',')[i]); CreateCatalogFile(article.Catalogid.ToString(), true, 0); CreateIndexFile(0); SiteGroupCms.Dal.ModuleContentDAL modulecontent = new SiteGroupCms.Dal.ModuleContentDAL(); if (article.Yyarticleid == 0) //不是引用 { if (article.Linkurl == "") //不是连接类型 { SiteGroupCms.Utils.DirFile.DeleteFile(modulecontent.Go2View(article.Id.ToString())); } } sucess = true; } new SiteGroupCms.Dal.LogDal().SaveLog(7); break; case "passarticle": if (articledal.PassById(id.Split(',')[i], 1, _admin.Id.ToString())) { sucess = true; } new SiteGroupCms.Dal.LogDal().SaveLog(4); break; case "rejectarticle": if (articledal.PassById(id.Split(',')[i], 0, "0")) { sucess = true; } new SiteGroupCms.Dal.LogDal().SaveLog(26); break; case "sharearticle": if (articledal.ShareById(id.Split(',')[i], 1)) { sucess = true; } new SiteGroupCms.Dal.LogDal().SaveLog(27); break; case "huishou": if (articledal.huihouById(id.Split(',')[i], 0)) { sucess = true; } new SiteGroupCms.Dal.LogDal().SaveLog(6); break; case "cddelete": if (articledal.DeleteByID(id.Split(',')[i])) { sucess = true; } new SiteGroupCms.Dal.LogDal().SaveLog(8); break; } } if (sucess)//成功删除 { _response += "{\"IsError\":false,\"Message\":\"加载成功\",\"Data\":{\"art\":0}}"; } else { _response += "{\"IsError\":true,\"Message\":\"加载失败\",\"Data\":{\"art\":0}}"; } Response.Write(_response); }