/// <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"); }
/// <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="_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(); } } }
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)); } }