Пример #1
0
 /// <summary>
 /// 获取 XML 内容
 /// </summary>
 /// <param name="title">标题</param>
 /// <param name="thisXmlText">本页单独的 XML 内容</param>
 /// <returns>返回完整的 XML 内容</returns>
 public string OutBaseXml(string title, string thisXmlText)
 {
     StringBuilder xml = new StringBuilder();
     xml.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
     xml.Append("<ui>\n");
     //配置数据
     xml.Append("\t<config>\n");
     xml.AppendFormat("\t\t<path>{0}</path>\n", SiteFun.CDATA(SiteCfg.Path));
     xml.AppendFormat("\t\t<system>{0}</system>\n", SiteFun.CDATA(SiteCfg.System));
     xml.AppendFormat("\t\t<version>{0}</version>\n", SiteFun.CDATA(SiteCfg.Version));
     xml.AppendFormat("\t\t<fullVersion>{0}</fullVersion>\n", SiteFun.CDATA(SiteCfg.SystemVersionFull));
     xml.AppendFormat("\t\t<powered>{0}</powered>\n", SiteFun.CDATA(SiteCfg.Powered));
     xml.Append("\t</config>\n");
     //设置数据
     SettingData setData = new SettingData(conn);
     if (SiteDat.GetDat(SiteCache.Setting) == null)
     {
         SiteDat.SetDat(SiteCache.Setting, setData.GetSetting());
     }
     SettingItem setting = (SettingItem)SiteDat.GetDat(SiteCache.Setting);
     string theme = setData.GetTheme;
     xml.Append("\t<setting>\n");
     xml.AppendFormat("\t\t<theme>{0}</theme>\n", SiteFun.CDATA(theme));
     xml.AppendFormat("\t\t<language>{0}</language>\n", SiteFun.CDATA(setting.Basic.Language));
     xml.AppendFormat("\t\t<name>{0}</name>\n", SiteFun.CDATA(setting.Basic.Name));
     xml.AppendFormat("\t\t<url>{0}</url>\n", SiteFun.CDATA(setting.Basic.URL));
     xml.AppendFormat("\t\t<intro>{0}</intro>\n", SiteFun.CDATA(setting.Basic.Intro));
     xml.AppendFormat("\t\t<keywords>{0}</keywords>\n", SiteFun.CDATA(setting.Basic.Keywords));
     xml.AppendFormat("\t\t<icp>{0}</icp>\n", SiteFun.CDATA(setting.Basic.ICP));
     xml.AppendFormat("\t\t<affiche>{0}</affiche>\n", SiteFun.CDATA(setting.Basic.Affiche));
     xml.Append("\t</setting>\n");
     //导航
     xml.Append("\t<navigations>\n");
     xml.Append("\t\t<item>\n");
     xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(SiteCfg.Path));
     xml.AppendFormat("\t\t\t<name>{0}</name>\n", SiteFun.CDATA(SiteDat.GetLan("HomePage")));
     xml.AppendFormat("\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(setting.Basic.Name));
     xml.AppendFormat("\t\t\t<target>{0}</target>\n", SiteFun.CDATA("_self"));
     xml.AppendFormat("\t\t\t<current>{0}</current>\n", string.IsNullOrEmpty(HttpContext.Current.Request.Url.Query));
     xml.Append("\t\t</item>\n");
     if (SiteDat.GetDat(SiteCache.Navigation) == null)
     {
         SiteDat.SetDat(SiteCache.Navigation, new ColumnData(conn).SelectColumn(1, -1, false));
     }
     foreach (ColumnItem vItem in (DataList<ColumnItem>)SiteDat.GetDat(SiteCache.Navigation))
     {
         string itemLink = string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Local));
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(vItem.Jump ? vItem.JumpUrl : itemLink));
         xml.AppendFormat("\t\t\t<name>{0}</name>\n", SiteFun.CDATA(vItem.Name));
         xml.AppendFormat("\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(vItem.Intro));
         xml.AppendFormat("\t\t\t<target>{0}</target>\n", SiteFun.CDATA(vItem.Target));
         xml.AppendFormat("\t\t\t<current>{0}</current>\n", string.Format((SiteFun.ToInt(vItem.Local) > 0 ? "?act=defa&cid={0}" : "?act=defa&clocal={1}"), vItem.ID, SiteFun.UrlEncode(vItem.Local)).ToLower() == HttpContext.Current.Request.Url.Query.ToLower());
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</navigations>\n");
     //分类
     xml.Append("\t<categorys>\n");
     if (SiteDat.GetDat(SiteCache.Column) == null)
     {
         SiteDat.SetDat(SiteCache.Column, new ColumnData(conn).SelectColumn(-1, 0, false));
     }
     foreach (ColumnItem vItem in (DataList<ColumnItem>)SiteDat.GetDat(SiteCache.Column))
     {
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Local))));
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<name>{0}</name>\n", SiteFun.CDATA(vItem.Name));
         xml.AppendFormat("\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(vItem.Intro));
         xml.AppendFormat("\t\t\t<local>{0}</local>\n", SiteFun.CDATA(vItem.Local));
         xml.AppendFormat("\t\t\t<postCount>{0}</postCount>\n", vItem.PostCount);
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</categorys>\n");
     //随机文章
     xml.Append("\t<randomArticles>\n");
     if (SiteDat.GetDat(SiteCache.RandomPost) == null)
     {
         SiteDat.SetDat(SiteCache.RandomPost, new PostData(conn).SelectPost(0, null, null, 1, setting.Parameter.AppendRandomArticleNum, 4, "A", false));
     }
     foreach (PostItem vItem in (DataList<PostItem>)SiteDat.GetDat(SiteCache.RandomPost))
     {
         ColumnItem columnItem = new ColumnItem();
         if (SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID)) == null)
         {
             SiteDat.SetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID), new ColumnData(conn).GetColumn(vItem.ColumnID));
         }
         columnItem = (ColumnItem)SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID));
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.ArticleLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Local))));
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<title>{0}</title>\n", SiteFun.CDATA(vItem.Title));
         xml.AppendFormat("\t\t\t<tags>{0}</tags>\n", SiteFun.CDATA(vItem.Tags));
         xml.AppendFormat("\t\t\t<local>{0}</local>\n", SiteFun.CDATA(vItem.Local));
         xml.AppendFormat("\t\t\t<author>{0}</author>\n", SiteFun.CDATA(vItem.Author));
         xml.AppendFormat("\t\t\t<postCount>{0}</postCount>\n", vItem.PostCount);
         xml.AppendFormat("\t\t\t<reader>{0}</reader>\n", vItem.Reader);
         xml.AppendFormat("\t\t\t<vote>{0}</vote>\n", vItem.Vote);
         xml.AppendFormat("\t\t\t<fine>{0}</fine>\n", vItem.Fine);
         xml.AppendFormat("\t\t\t<publish>{0}</publish>\n", vItem.Publish);
         xml.Append("\t\t\t<category>\n");
         xml.AppendFormat("\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(columnItem.Local))));
         xml.AppendFormat("\t\t\t\t<id>{0}</id>\n", columnItem.ID);
         xml.AppendFormat("\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(columnItem.Local));
         xml.AppendFormat("\t\t\t\t<name>{0}</name>\n", SiteFun.CDATA(columnItem.Name));
         xml.AppendFormat("\t\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(columnItem.Intro));
         xml.AppendFormat("\t\t\t\t<postCount>{0}</postCount>\n", columnItem.PostCount);
         xml.Append("\t\t\t</category>\n");
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</randomArticles>\n");
     //热门文章
     xml.Append("\t<hotArticles>\n");
     if (SiteDat.GetDat(SiteCache.HotPost) == null)
     {
         SiteDat.SetDat(SiteCache.HotPost, new PostData(conn).SelectPost(0, null, null, 1, setting.Parameter.AppendHotArticleNum, 2, "A", false));
     }
     foreach (PostItem vItem in (DataList<PostItem>)SiteDat.GetDat(SiteCache.HotPost))
     {
         ColumnItem columnItem = new ColumnItem();
         if (SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID)) == null)
         {
             SiteDat.SetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID), new ColumnData(conn).GetColumn(vItem.ColumnID));
         }
         columnItem = (ColumnItem)SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID));
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.ArticleLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Local))));
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<title>{0}</title>\n", SiteFun.CDATA(vItem.Title));
         xml.AppendFormat("\t\t\t<tags>{0}</tags>\n", SiteFun.CDATA(vItem.Tags));
         xml.AppendFormat("\t\t\t<local>{0}</local>\n", SiteFun.CDATA(vItem.Local));
         xml.AppendFormat("\t\t\t<author>{0}</author>\n", SiteFun.CDATA(vItem.Author));
         xml.AppendFormat("\t\t\t<postCount>{0}</postCount>\n", vItem.PostCount);
         xml.AppendFormat("\t\t\t<reader>{0}</reader>\n", vItem.Reader);
         xml.AppendFormat("\t\t\t<vote>{0}</vote>\n", vItem.Vote);
         xml.AppendFormat("\t\t\t<fine>{0}</fine>\n", vItem.Fine);
         xml.AppendFormat("\t\t\t<publish>{0}</publish>\n", vItem.Publish);
         xml.Append("\t\t\t<category>\n");
         xml.AppendFormat("\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(columnItem.Local))));
         xml.AppendFormat("\t\t\t\t<id>{0}</id>\n", columnItem.ID);
         xml.AppendFormat("\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(columnItem.Local));
         xml.AppendFormat("\t\t\t\t<name>{0}</name>\n", SiteFun.CDATA(columnItem.Name));
         xml.AppendFormat("\t\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(columnItem.Intro));
         xml.AppendFormat("\t\t\t\t<postCount>{0}</postCount>\n", columnItem.PostCount);
         xml.Append("\t\t\t</category>\n");
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</hotArticles>\n");
     //好文章
     xml.Append("\t<fineArticles>\n");
     if (SiteDat.GetDat(SiteCache.FinePost) == null)
     {
         SiteDat.SetDat(SiteCache.FinePost, new PostData(conn).SelectPost(0, null, null, 1, setting.Parameter.AppendFineArticleNum, 3, "A", false));
     }
     foreach (PostItem vItem in (DataList<PostItem>)SiteDat.GetDat(SiteCache.FinePost))
     {
         ColumnItem columnItem = new ColumnItem();
         if (SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID)) == null)
         {
             SiteDat.SetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID), new ColumnData(conn).GetColumn(vItem.ColumnID));
         }
         columnItem = (ColumnItem)SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID));
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.ArticleLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Local))));
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<title>{0}</title>\n", SiteFun.CDATA(vItem.Title));
         xml.AppendFormat("\t\t\t<tags>{0}</tags>\n", SiteFun.CDATA(vItem.Tags));
         xml.AppendFormat("\t\t\t<local>{0}</local>\n", SiteFun.CDATA(vItem.Local));
         xml.AppendFormat("\t\t\t<author>{0}</author>\n", SiteFun.CDATA(vItem.Author));
         xml.AppendFormat("\t\t\t<postCount>{0}</postCount>\n", vItem.PostCount);
         xml.AppendFormat("\t\t\t<reader>{0}</reader>\n", vItem.Reader);
         xml.AppendFormat("\t\t\t<vote>{0}</vote>\n", vItem.Vote);
         xml.AppendFormat("\t\t\t<fine>{0}</fine>\n", vItem.Fine);
         xml.AppendFormat("\t\t\t<publish>{0}</publish>\n", vItem.Publish);
         xml.Append("\t\t\t<category>\n");
         xml.AppendFormat("\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(columnItem.Local))));
         xml.AppendFormat("\t\t\t\t<id>{0}</id>\n", columnItem.ID);
         xml.AppendFormat("\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(columnItem.Local));
         xml.AppendFormat("\t\t\t\t<name>{0}</name>\n", SiteFun.CDATA(columnItem.Name));
         xml.AppendFormat("\t\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(columnItem.Intro));
         xml.AppendFormat("\t\t\t\t<postCount>{0}</postCount>\n", columnItem.PostCount);
         xml.Append("\t\t\t</category>\n");
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</fineArticles>\n");
     //最新评论
     xml.Append("\t<newComments>\n");
     if (SiteDat.GetDat(SiteCache.NewComment) == null)
     {
         SiteDat.SetDat(SiteCache.NewComment, new CommentData(conn).SelectComment(0, 1, setting.Parameter.AppendNewCommentNum, false));
     }
     foreach (CommentItem vItem in (DataList<CommentItem>)SiteDat.GetDat(SiteCache.NewComment))
     {
         PostItem postItem = new PostData(conn).GetPost(vItem.PostID);
         ColumnItem columnItem = new ColumnItem();
         if (SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, postItem.ColumnID)) == null)
         {
             SiteDat.SetDat(string.Format(SiteCache.ColumnFormat, postItem.ColumnID), new ColumnData(conn).GetColumn(postItem.ColumnID));
         }
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<author>{0}</author>\n", SiteFun.CDATA(vItem.Author));
         xml.AppendFormat("\t\t\t<title>{0}</title>\n", SiteFun.CDATA(vItem.Title));
         xml.AppendFormat("\t\t\t<content>{0}</content>\n", SiteFun.CDATA(vItem.Content));
         xml.AppendFormat("\t\t\t<reply>{0}</reply>\n", SiteFun.CDATA(vItem.Reply));
         xml.AppendFormat("\t\t\t<mail>{0}</mail>\n", SiteFun.CDATA(vItem.Mail));
         xml.AppendFormat("\t\t\t<url>{0}</url>\n", SiteFun.CDATA(vItem.URL));
         xml.AppendFormat("\t\t\t<publish>{0}</publish>\n", vItem.Publish);
         xml.AppendFormat("\t\t\t<trackback>{0}</trackback>\n", vItem.Trackback);
         xml.Append("\t\t\t<article>\n");
         xml.AppendFormat("\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.ArticleLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(postItem.Local))));
         xml.AppendFormat("\t\t\t\t<id>{0}</id>\n", postItem.ID);
         xml.AppendFormat("\t\t\t\t<title>{0}</title>\n", SiteFun.CDATA(postItem.Title));
         xml.AppendFormat("\t\t\t\t<tags>{0}</tags>\n", SiteFun.CDATA(postItem.Tags));
         xml.AppendFormat("\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(postItem.Local));
         xml.AppendFormat("\t\t\t\t<author>{0}</author>\n", SiteFun.CDATA(postItem.Author));
         xml.AppendFormat("\t\t\t\t<postCount>{0}</postCount>\n", postItem.PostCount);
         xml.AppendFormat("\t\t\t\t<reader>{0}</reader>\n", postItem.Reader);
         xml.AppendFormat("\t\t\t\t<vote>{0}</vote>\n", postItem.Vote);
         xml.AppendFormat("\t\t\t\t<fine>{0}</fine>\n", postItem.Fine);
         xml.AppendFormat("\t\t\t\t<publish>{0}</publish>\n", postItem.Publish);
         xml.Append("\t\t\t\t<category>\n");
         xml.AppendFormat("\t\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(columnItem.Local))));
         xml.AppendFormat("\t\t\t\t\t<id>{0}</id>\n", columnItem.ID);
         xml.AppendFormat("\t\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(columnItem.Local));
         xml.AppendFormat("\t\t\t\t\t<name>{0}</name>\n", SiteFun.CDATA(columnItem.Name));
         xml.AppendFormat("\t\t\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(columnItem.Intro));
         xml.AppendFormat("\t\t\t\t\t<postCount>{0}</postCount>\n", columnItem.PostCount);
         xml.Append("\t\t\t\t</category>\n");
         xml.Append("\t\t\t</article>\n");
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</newComments>\n");
     //单页面
     xml.Append("\t<pages>\n");
     if (SiteDat.GetDat(SiteCache.Page) == null)
     {
         SiteDat.SetDat(SiteCache.Page, new PostData(conn).SelectPost(0, null, null, 1, 999, 0, "P", false));
     }
     foreach (PostItem vItem in (DataList<PostItem>)SiteDat.GetDat(SiteCache.Page))
     {
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.PageLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Local))));
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<title>{0}</title>\n", SiteFun.CDATA(vItem.Title));
         xml.AppendFormat("\t\t\t<local>{0}</local>\n", SiteFun.CDATA(vItem.Local));
         xml.AppendFormat("\t\t\t<publish>{0}</publish>\n", vItem.Publish);
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</pages>\n");
     //热门标签
     xml.Append("\t<tags>\n");
     if (SiteDat.GetDat(SiteCache.HotTag) == null)
     {
         SiteDat.SetDat(SiteCache.HotTag, new TagData(conn).SelectTag(1, setting.Parameter.AppendHotTagNum, "PostCount", "DESC"));
     }
     foreach (TagItem vItem in (TagList)SiteDat.GetDat(SiteCache.HotTag))
     {
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.TagLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Key))));
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<key>{0}</key>\n", SiteFun.CDATA(vItem.Key));
         xml.AppendFormat("\t\t\t<postCount>{0}</postCount>\n", vItem.PostCount);
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</tags>\n");
     //首页链接
     xml.Append("\t<fellows>\n");
     if (SiteDat.GetDat(SiteCache.Fellow) == null)
     {
         SiteDat.SetDat(SiteCache.Fellow, new FellowData(conn).SelectFellow(1, int.MaxValue, true, false));
     }
     DataList<FellowItem> fellows = (DataList<FellowItem>)SiteDat.GetDat(SiteCache.Fellow);
     foreach (FellowItem vItem in fellows)
     {
         xml.Append("\t\t<item>\n");
         xml.AppendFormat("\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t<name>{0}</name>\n", SiteFun.CDATA(vItem.Name));
         xml.AppendFormat("\t\t\t<url>{0}</url>\n", SiteFun.CDATA(vItem.URL));
         xml.AppendFormat("\t\t\t<logo>{0}</logo>\n", SiteFun.CDATA(vItem.Logo));
         xml.AppendFormat("\t\t\t<explain>{0}</explain>\n", SiteFun.CDATA(SiteFun.HtmlMatch(vItem.Explain)));
         xml.AppendFormat("\t\t\t<style>{0}</style>\n", SiteFun.CDATA(vItem.Style));
         xml.Append("\t\t</item>\n");
     }
     xml.Append("\t</fellows>\n");
     //自定义标签
     xml.Append("\t<myTag>\n");
     if (SiteDat.GetDat(SiteCache.MyTag) == null)
     {
         SiteDat.SetDat(SiteCache.MyTag, new MyTagData(conn).SelectMyTag(1, int.MaxValue, false));
     }
     foreach (MyTagItem vItem in (DataList<MyTagItem>)SiteDat.GetDat(SiteCache.MyTag))
     {
         xml.AppendFormat("\t\t<{0}>{1}</{0}>\n", vItem.Key, SiteFun.CDATA(vItem.Code));
     }
     xml.Append("\t</myTag>\n");
     //单页数据
     xml.Append("\t<this>\n");
     xml.AppendFormat("\t\t<title>{0}</title>\n", SiteFun.CDATA(title));
     xml.Append(thisXmlText);
     xml.Append("\t</this>\n");
     //扩展部分
     xml.Append("\t<expand>\n");
     foreach (object type in new SiteExpand().GetTypes(typeof(IWebExpandXml).FullName))
     {
         IWebExpandXml iae = ((IWebExpandXml)type);
         xml.Append(iae.OutXML());
     }
     xml.Append("\t</expand>\n");
     xml.Append("</ui>\n");
     return xml.ToString();
 }
Пример #2
0
 /// <summary>
 /// 筛选分类
 /// </summary>
 /// <param name="nav">是否是导航,-1:默认,0:不是,1:是</param>
 /// <param name="jump">是否是外链,-1:默认,0:不是,1:是</param>
 /// <param name="selAll">是否筛选所有数据</param>
 /// <returns>返回分类数据列表</returns>
 public DataList<ColumnItem> SelectColumn(int nav, int jump, bool selAll)
 {
     DataList<ColumnItem> list = new DataList<ColumnItem>();
     string where = selAll ? string.Empty : " AND [Show] <> 0";
     switch (nav)
     {
         case 0: { where += " AND [IsNav] = 0"; break; }
         case 1: { where += " AND [IsNav] <> 0"; break; }
     }
     switch (jump)
     {
         case 0: { where += " AND [IsJump] = 0"; break; }
         case 1: { where += " AND [IsJump] <> 0"; break; }
     }
     list.Number = Convert.ToInt32(conn.ExecuteScalar(string.Format("SELECT COUNT([ID]) FROM [Column] WHERE [ID] > 0{0};", where)));
     using (IDataReader reader = conn.ExecuteReader(string.Format("SELECT [ID], [Name], [Local], [Intro], [Sorting], [PostCount], [Show], [IsNav], [IsJump], [JumpUrl], [Target], [ListTpl], [ViewTpl], [PageSize] FROM [Column] WHERE [ID] > 0{0} ORDER BY [Sorting] ASC, [ID] ASC", where)))
     {
         while (reader.Read())
         {
             ColumnItem item = new ColumnItem();
             item.ID = reader.GetInt32(0);
             item.Name = reader.GetString(1);
             item.Local = reader.GetString(2);
             item.Intro = reader.GetString(3);
             item.Sorting = reader.GetInt32(4);
             item.PostCount = reader.GetInt32(5);
             item.Show = reader.GetInt32(6) == 0 ? false : true;
             item.Nav = reader.GetInt32(7) == 0 ? false : true;
             item.Jump = reader.GetInt32(8) == 0 ? false : true;
             item.JumpUrl = reader.GetString(9);
             item.Target = reader.GetString(10);
             item.ListTemplate = reader.GetString(11);
             item.ViewTemplate = reader.GetString(12);
             item.PageSize = reader.GetInt32(13);
             list.Add(item);
         }
     }
     return list;
 }
Пример #3
0
 /// <summary>
 /// 修改一个分类
 /// </summary>
 /// <param name="value">分类数据</param>
 /// <returns>返回被修改的分类的ID</returns>
 public int UpdateColumn(ColumnItem value)
 {
     int id = 0;
     _DbParameter[] pars ={
                             new _DbParameter().Set("@Name", DbType.String, value.Name),
                             new _DbParameter().Set("@Local", DbType.String, value.Local),
                             new _DbParameter().Set("@Intro", DbType.String, value.Intro),
                             new _DbParameter().Set("@Sorting", DbType.Int32, value.Sorting),
                             new _DbParameter().Set("@Show", DbType.Int32, value.Show ? 1 : 0),
                             new _DbParameter().Set("@Nav", DbType.Int32, value.Nav ? 1 : 0),
                             new _DbParameter().Set("@Jump", DbType.Int32, value.Jump ? 1 : 0),
                             new _DbParameter().Set("@JumpUrl", DbType.String, value.JumpUrl),
                             new _DbParameter().Set("@Target", DbType.String, value.Target),
                             new _DbParameter().Set("@ListTemplate", DbType.String, value.ListTemplate),
                             new _DbParameter().Set("@ViewTemplate", DbType.String, value.ViewTemplate),
                             new _DbParameter().Set("@PageSize", DbType.Int32, value.PageSize),
                             new _DbParameter().Set("@ID", DbType.Int32, value.ID)
                         };
     conn.ExecuteNonQuery("UPDATE [Column] SET [Name] = @Name, [Local] = @Local, [Intro] = @Intro, [Sorting] = @Sorting, [Show] = @Show, [IsNav] = @Nav, [IsJump] = @Jump, [JumpUrl] = @JumpUrl, [Target] = @Target, [ListTpl] = @ListTemplate, [ViewTpl] = @ViewTemplate, [PageSize] = @PageSize WHERE [ID] = @ID", pars);
     id = value.ID;
     if (string.IsNullOrEmpty(value.Local))
     {
         conn.ExecuteNonQuery(string.Format("UPDATE [Column] SET [Local] = [ID] WHERE [ID] = {0}", id));
     }
     return id;
 }
Пример #4
0
 /// <summary>
 /// 根据分类名取得分类
 /// </summary>
 /// <param name="name">分类名称</param>
 /// <returns>返回分类数据</returns>
 public ColumnItem GetColumnForName(string name)
 {
     _DbParameter[] pars ={
                              new _DbParameter().Set("@Name", DbType.String, name)
                          };
     ColumnItem item = new ColumnItem();
     int rows = 0;
     using (IDataReader reader = conn.ExecutePager("[Column]", "[ID], [Name], [Local], [Intro], [Sorting], [PostCount], [Show], [IsNav], [IsJump], [JumpUrl], [Target], [ListTpl], [ViewTpl], [PageSize]", "[Name] = @Name", null, null, 1, 1, pars, ref rows))
     {
         while (reader.Read())
         {
             item.ID = reader.GetInt32(0);
             item.Name = reader.GetString(1);
             item.Local = reader.GetString(2);
             item.Intro = reader.GetString(3);
             item.Sorting = reader.GetInt32(4);
             item.PostCount = reader.GetInt32(5);
             item.Show = reader.GetInt32(6) == 0 ? false : true;
             item.Nav = reader.GetInt32(7) == 0 ? false : true;
             item.Jump = reader.GetInt32(8) == 0 ? false : true;
             item.JumpUrl = reader.GetString(9);
             item.Target = reader.GetString(10);
             item.ListTemplate = reader.GetString(11);
             item.ViewTemplate = reader.GetString(12);
             item.PageSize = reader.GetInt32(13);
         }
     }
     return item;
 }
Пример #5
0
 /// <summary>
 /// 添加一个分类
 /// </summary>
 /// <param name="value">分类数据</param>
 /// <returns>返回新增的分类的ID</returns>
 public int InsertColumn(ColumnItem value)
 {
     int id = 0;
     _DbParameter[] pars ={
                             new _DbParameter().Set("@Name", DbType.String, value.Name),
                             new _DbParameter().Set("@Local", DbType.String, value.Local),
                             new _DbParameter().Set("@Intro", DbType.String, value.Intro),
                             new _DbParameter().Set("@Sorting", DbType.Int32, value.Sorting),
                             new _DbParameter().Set("@Show", DbType.Int32, value.Show ? 1 : 0),
                             new _DbParameter().Set("@Nav", DbType.Int32, value.Nav ? 1 : 0),
                             new _DbParameter().Set("@Jump", DbType.Int32, value.Jump ? 1 : 0),
                             new _DbParameter().Set("@JumpUrl", DbType.String, value.JumpUrl),
                             new _DbParameter().Set("@Target", DbType.String, value.Target),
                             new _DbParameter().Set("@ListTemplate", DbType.String, value.ListTemplate),
                             new _DbParameter().Set("@ViewTemplate", DbType.String, value.ViewTemplate),
                             new _DbParameter().Set("@PageSize", DbType.Int32, value.PageSize)
                         };
     conn.ExecuteNonQuery("INSERT INTO [Column] ([Name], [Local], [Intro], [Sorting], [Show], [IsNav], [IsJump], [JumpUrl], [Target], [ListTpl], [ViewTpl], [PageSize]) VALUES (@Name, @Local, @Intro, @Sorting, @Show, @Nav, @Jump, @JumpUrl, @Target, @ListTemplate, @ViewTemplate, @PageSize)", pars);
     id = Convert.ToInt32(conn.ExecuteNewField("[Column]", null, null));
     if (string.IsNullOrEmpty(value.Local))
     {
         conn.ExecuteNonQuery(string.Format("UPDATE [Column] SET [Local] = [ID] WHERE [ID] = {0}", id));
     }
     return id;
 }
Пример #6
0
 /// <summary>
 /// 取得分类
 /// </summary>
 /// <param name="id">分类编号</param>
 /// <returns>返回分类数据</returns>
 public ColumnItem GetColumn(int id)
 {
     ColumnItem item = new ColumnItem();
     int rows = 0;
     using (IDataReader reader = conn.ExecutePager("[Column]", "[ID], [Name], [Local], [Intro], [Sorting], [PostCount], [Show], [IsNav], [IsJump], [JumpUrl], [Target], [ListTpl], [ViewTpl], [PageSize]", string.Format("[ID] = {0}", id), null, null, 1, 1, ref rows))
     {
         while (reader.Read())
         {
             item.ID = reader.GetInt32(0);
             item.Name = reader.GetString(1);
             item.Local = reader.GetString(2);
             item.Intro = reader.GetString(3);
             item.Sorting = reader.GetInt32(4);
             item.PostCount = reader.GetInt32(5);
             item.Show = reader.GetInt32(6) == 0 ? false : true;
             item.Nav = reader.GetInt32(7) == 0 ? false : true;
             item.Jump = reader.GetInt32(8) == 0 ? false : true;
             item.JumpUrl = reader.GetString(9);
             item.Target = reader.GetString(10);
             item.ListTemplate = reader.GetString(11);
             item.ViewTemplate = reader.GetString(12);
             item.PageSize = reader.GetInt32(13);
         }
     }
     return item;
 }
Пример #7
0
 /// <summary>
 ///  获取文章列表页完整XML内容
 /// </summary>
 /// <param name="cateId">分类编号</param>
 /// <param name="cateLocal">分类标签名</param>
 /// <param name="tag">搜索标签名</param>
 /// <param name="key">搜索关键字</param>
 /// <param name="page">当前页</param>
 /// <param name="pageSize">分页大小</param>
 /// <returns>完整XML内容</returns>
 public string OutWriteList(int cateId, string cateLocal, string tag, string key, int page, int pageSize)
 {
     SettingItem setting = this.OutSetting;
     ColumnItem cateItem = new ColumnItem();
     if (cateId > 0) { cateItem = new ColumnData(conn).GetColumn(cateId); }
     else { cateItem = new ColumnData(conn).GetColumn(cateLocal); }
     string listCacheName = string.Format(SiteCache.PostsListFormat, page, cateItem.ID, tag, key);
     if (SiteDat.GetDat(listCacheName) == null)
     {
         SiteDat.SetDat(listCacheName, new PostData(conn).SelectPost(cateItem.ID, tag, key, page, pageSize, 0, "A", false));
     }
     DataList<PostItem> artList = (DataList<PostItem>)SiteDat.GetDat(listCacheName);
     //本页XML处理
     StringBuilder xml = new StringBuilder();
     xml.AppendFormat("\t\t<tagName>{0}</tagName>\n", SiteFun.CDATA(tag));
     xml.AppendFormat("\t\t<searchKey>{0}</searchKey>\n", SiteFun.CDATA(key));
     xml.AppendFormat("\t\t<categoryName>{0}</categoryName>\n", SiteFun.CDATA(cateItem.Name));
     xml.Append("\t\t<articles>\n");
     //取得文章列表数据
     string pagerLink = string.Format(SitePath.PagerFormat, SiteCfg.Path, cateItem.ID, SiteFun.UrlEncode(tag), SiteFun.UrlEncode(key), "{0}");
     xml.AppendFormat("\t\t\t<pages>{0}</pages>\n", SiteFun.CDATA(new SitePages().Make(artList.Number, page, pageSize, pagerLink)));
     foreach (PostItem vItem in artList)
     {
         ColumnItem columnItem = new ColumnItem();
         if (SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID)) == null)
         {
             SiteDat.SetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID), new ColumnData(conn).GetColumn(vItem.ColumnID));
         }
         columnItem = (ColumnItem)SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, vItem.ColumnID));
         xml.Append("\t\t\t<item>\n");
         xml.AppendFormat("\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.ArticleLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(vItem.Local))));
         xml.AppendFormat("\t\t\t\t<id>{0}</id>\n", vItem.ID);
         xml.AppendFormat("\t\t\t\t<title>{0}</title>\n", SiteFun.CDATA(vItem.Title));
         xml.AppendFormat("\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(vItem.Local));
         xml.AppendFormat("\t\t\t\t<tags>{0}</tags>\n", SiteFun.CDATA(vItem.Tags));
         xml.AppendFormat("\t\t\t\t<explain>{0}</explain>\n", SiteFun.CDATA(CheckPasswordContent(vItem.Password, vItem.Explain, vItem.Local, false)));
         xml.AppendFormat("\t\t\t\t<content>{0}</content>\n", SiteFun.CDATA(CheckPasswordContent(vItem.Password, vItem.Content, vItem.Local, false)));
         xml.AppendFormat("\t\t\t\t<publish>{0}</publish>\n", vItem.Publish);
         xml.AppendFormat("\t\t\t\t<author>{0}</author>\n", SiteFun.CDATA(vItem.Author));
         xml.AppendFormat("\t\t\t\t<postCount>{0}</postCount>\n", vItem.PostCount);
         xml.AppendFormat("\t\t\t\t<reader>{0}</reader>\n", vItem.Reader);
         xml.AppendFormat("\t\t\t\t<vote>{0}</vote>\n", vItem.Vote);
         xml.AppendFormat("\t\t\t\t<fine>{0}</fine>\n", vItem.Fine);
         xml.Append("\t\t\t\t<category>\n");
         xml.AppendFormat("\t\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(columnItem.Local))));
         xml.AppendFormat("\t\t\t\t\t<id>{0}</id>\n", columnItem.ID);
         xml.AppendFormat("\t\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(columnItem.Local));
         xml.AppendFormat("\t\t\t\t\t<name>{0}</name>\n", SiteFun.CDATA(columnItem.Name));
         xml.AppendFormat("\t\t\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(columnItem.Intro));
         xml.AppendFormat("\t\t\t\t\t<postCount>{0}</postCount>\n", columnItem.PostCount);
         xml.Append("\t\t\t\t</category>\n");
         xml.Append("\t\t\t</item>\n");
     }
     xml.Append("\t\t</articles>\n");
     //绑定XML并写出
     string title = string.Format("{0} - {1}", setting.Basic.Name, setting.Basic.Intro);
     if (cateItem.ID > 0) { title = string.Format("{0}: {1} - {2}", SiteDat.GetLan("Category"), cateItem.Name, setting.Basic.Name); }
     if (!string.IsNullOrEmpty(tag)) { title = string.Format("{0}: {1} - {2}", SiteDat.GetLan("Tag"), tag, setting.Basic.Name); }
     if (!string.IsNullOrEmpty(key)) { title = string.Format("{0}: {1} - {2}", SiteDat.GetLan("Search"), key, setting.Basic.Name); }
     return new _WebBaseXml(conn).OutBaseXml(title, xml.ToString());
 }
Пример #8
0
        /// <summary>
        /// 获取文章内容页完整XML内容
        /// </summary>
        /// <param name="id">文章编号</param>
        /// <param name="local">文章标签</param>
        /// <param name="pwd">文章密码</param>
        /// <param name="page">当前页(评论用)</param>
        /// <param name="pageSize">分页大小(评论用)</param>
        /// <returns>完整XML内容</returns>
        public string OutWriteView(int id, string local, string pwd, int page, int pageSize)
        {
            SettingItem setting = this.OutSetting;
            PostData artData = new PostData(conn);
            SiteDat SiteDat = new SiteDat();
            //取得文章列表数据
            PostItem art = new PostItem();
            if (id > 0)
            {
                if (SiteDat.GetDat(string.Format(SiteCache.PostFormat, id)) == null)
                {
                    SiteDat.SetDat(string.Format(SiteCache.PostFormat, id), artData.GetPost(id));
                }
                art = (PostItem)SiteDat.GetDat(string.Format(SiteCache.PostFormat, id));
            }
            else
            {
                if (SiteDat.GetDat(string.Format(SiteCache.PostFormat, local)) == null)
                {
                    SiteDat.SetDat(string.Format(SiteCache.PostFormat, local), artData.GetPost(local));
                }
                art = (PostItem)SiteDat.GetDat(string.Format(SiteCache.PostFormat, local));
            }
            //取得栏目数据
            ColumnItem columnItem = new ColumnItem();
            if (SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, art.ColumnID)) == null)
            {
                SiteDat.SetDat(string.Format(SiteCache.ColumnFormat, art.ColumnID), new ColumnData(conn).GetColumn(art.ColumnID));
            }
            columnItem = (ColumnItem)SiteDat.GetDat(string.Format(SiteCache.ColumnFormat, art.ColumnID));

            artData.AddPostReader(art.ID);
            //设置模板引擎
            //设置密码文章显示状态
            bool viewPwdArt = pwd == art.Password;
            //本页XML处理
            StringBuilder xml = new StringBuilder();
            xml.Append("\t\t<article>\n");
            xml.AppendFormat("\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.ArticleLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(art.Local))));
            xml.AppendFormat("\t\t\t\t<id>{0}</id>\n", art.ID);
            xml.AppendFormat("\t\t\t\t<title>{0}</title>\n", SiteFun.CDATA(art.Title));
            xml.AppendFormat("\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(art.Local));
            xml.AppendFormat("\t\t\t\t<tags>{0}</tags>\n", SiteFun.CDATA(art.Tags));
            xml.Append("\t\t\t\t<category>\n");
            xml.AppendFormat("\t\t\t\t\t<link>{0}</link>\n", SiteFun.CDATA(string.Format(SitePath.CategoryLinkFormat, SiteCfg.Path, SiteFun.UrlEncode(columnItem.Local))));
            xml.AppendFormat("\t\t\t\t\t<id>{0}</id>\n", columnItem.ID);
            xml.AppendFormat("\t\t\t\t\t<local>{0}</local>\n", SiteFun.CDATA(columnItem.Local));
            xml.AppendFormat("\t\t\t\t\t<name>{0}</name>\n", SiteFun.CDATA(columnItem.Name));
            xml.AppendFormat("\t\t\t\t\t<intro>{0}</intro>\n", SiteFun.CDATA(columnItem.Intro));
            xml.AppendFormat("\t\t\t\t\t<postCount>{0}</postCount>\n", columnItem.PostCount);
            xml.Append("\t\t\t\t</category>\n");
            xml.AppendFormat("\t\t\t\t<explain>{0}</explain>\n", SiteFun.CDATA(CheckPasswordContent(art.Password, art.Explain, art.Local, viewPwdArt)));
            xml.AppendFormat("\t\t\t\t<content>{0}</content>\n", SiteFun.CDATA(CheckPasswordContent(art.Password, art.Content, art.Local, viewPwdArt)));
            xml.AppendFormat("\t\t\t\t<publish>{0}</publish>\n", art.Publish);
            xml.AppendFormat("\t\t\t\t<author>{0}</author>\n", SiteFun.CDATA(art.Author));
            xml.AppendFormat("\t\t\t\t<postCount>{0}</postCount>\n", art.PostCount);
            xml.AppendFormat("\t\t\t\t<reader>{0}</reader>\n", art.Reader);
            xml.AppendFormat("\t\t\t\t<vote>{0}</vote>\n", art.Vote);
            xml.Append("\t\t</article>\n");
            xml.Append("\t\t<comments>\n");
            xml.AppendFormat("\t\t\t<html>{0}</html>\n", SiteFun.CDATA(new CommentUI(conn).GetCommentList(art.ID, page, pageSize)));
            xml.Append("\t\t</comments>\n");
            //绑定XML并写出
            string title = string.Empty;
            if (art.ID > 0) { title = string.Format("{0} - {1} - {2}", art.Title, columnItem.Name, setting.Basic.Name); }
            return new _WebBaseXml(conn).OutBaseXml(title, xml.ToString());
        }
Пример #9
0
 /// <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&amp;mode=post&amp;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();
 }
Пример #10
0
 /// <summary>
 /// 提交分类数据
 /// </summary>
 /// <returns>返回发布分类代码</returns>
 public string Post()
 {
     StringBuilder sr = new StringBuilder();
     int id = SiteFun.ToInt(SiteFun.Query("id"));
     string theme = new SettingData(conn).GetTheme;
     ColumnData cateData = new ColumnData(conn);
     //取得默认值
     ColumnItem old = cateData.GetColumn(id);
     if (old.ID == 0)
     {
         //默认显示
         old.Show = true;
     }
     if (SiteFun.IsPost)
     {
         ColumnItem postVal = new ColumnItem();
         postVal.ID = id;
         postVal.Name = SiteFun.Post("name");
         postVal.Local = SiteFun.Post("local");
         postVal.Target = SiteFun.Post("target");
         postVal.ListTemplate = SiteFun.Post("listTpl");
         postVal.ViewTemplate = SiteFun.Post("viewTpl");
         postVal.PageSize = SiteFun.ToInt(SiteFun.Post("pageSize"));
         postVal.Jump = SiteFun.ToInt(SiteFun.Post("jump")) == 0 ? false : true;
         postVal.JumpUrl = SiteFun.Post("jumpUrl");
         postVal.Intro = SiteFun.Post("intro");
         postVal.Sorting = SiteFun.ToInt(SiteFun.Post("sorting"));
         postVal.Nav = SiteFun.ToInt(SiteFun.Post("nav")) == 0 ? false : true;
         postVal.Show = SiteFun.ToInt(SiteFun.Post("show")) == 0 ? false : true;
         if (string.IsNullOrEmpty(postVal.Name)) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoName"))); }
         else
         {
             if (!string.IsNullOrEmpty(postVal.Local)) { postVal.Local = postVal.Local.Replace(" ", "-"); }
             if (!string.IsNullOrEmpty(postVal.Local) && (!SiteFun.IsLocal(postVal.Local) || cateData.ExistsLocal(postVal.Local, postVal.ID))) { sr.Append(AdminUI.ErrorBox(SiteDat.GetLan("MsgNoLocalOrExists"))); }
             else
             {
                 if (postVal.ID == 0)
                 {
                     cateData.InsertColumn(postVal);
                     sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgInsertDat"), "?act=column&mode=list"));
                 }
                 else
                 {
                     cateData.UpdateColumn(postVal);
                     sr.Append(AdminUI.SuccessBox(SiteDat.GetLan("MsgUpdateDat"), "?act=column&mode=list"));
                 }
             }
         }
         ClearCache();
         old = postVal;
     }
     sr.Append(AdminUI.AdminBoxStart(true));
     sr.Append(HtmlUI.FormStart());
     sr.Append(HtmlUI.TableStart("onCenter"));
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Name")) + HtmlUI.CreateTd(HtmlUI.Input("name", 20, null, SiteFun.HtmlEncode(old.Name))));
     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(SitePath.CategoryLinkFormat, null, HtmlUI.Input("local", 15, null, SiteFun.HtmlEncode(old.Local)))));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(HtmlUI.CheckBoxInput(SiteDat.GetLan("Jump"), "jump", 1, old.Jump) + HtmlUI.Input("jumpUrl", 50, null, SiteFun.HtmlEncode(old.JumpUrl))));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Intro")) + HtmlUI.CreateTd(HtmlUI.Input("intro", 50, null, SiteFun.HtmlEncode(old.Intro))));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Sorting")) + HtmlUI.CreateTd(HtmlUI.Input("sorting", 5, null, old.Sorting)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Target")) + HtmlUI.CreateTd(HtmlUI.Input("target", 10, null, SiteFun.HtmlEncode(old.Target))));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("ListTpl")) + HtmlUI.CreateTd(string.Format(SitePath.ThemePathFormat, theme, HtmlUI.Input("listTpl", 15, null, SiteFun.HtmlEncode(old.ListTemplate)))));
     sr.Append(HtmlUI.TrFinal());
     if (!string.IsNullOrEmpty(old.ListTemplate) && !File.Exists(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, theme, old.ListTemplate))))
     {
         sr.Append(HtmlUI.TrStart());
         sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(string.Format(SiteDat.GetLan("MsgFileNotExistsFormat"), old.ListTemplate)));
         sr.Append(HtmlUI.TrFinal());
     }
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("ViewTpl")) + HtmlUI.CreateTd(string.Format(SitePath.ThemePathFormat, theme, HtmlUI.Input("viewTpl", 15, null, SiteFun.HtmlEncode(old.ViewTemplate)))));
     sr.Append(HtmlUI.TrFinal());
     if (!string.IsNullOrEmpty(old.ViewTemplate) && !File.Exists(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, theme, old.ViewTemplate))))
     {
         sr.Append(HtmlUI.TrStart());
         sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(string.Format(SiteDat.GetLan("MsgFileNotExistsFormat"), old.ViewTemplate)));
         sr.Append(HtmlUI.TrFinal());
     }
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("PageSize")) + HtmlUI.CreateTd(HtmlUI.Input("pageSize", 5, null, old.PageSize)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh(SiteDat.GetLan("Virtue")) + HtmlUI.CreateTd(HtmlUI.CheckBoxInput(SiteDat.GetLan("Nav"), "nav", 1, old.Nav) + HtmlUI.CheckBoxInput(SiteDat.GetLan("Show"), "show", 1, old.Show)));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TrStart());
     sr.Append(HtmlUI.CreateTh() + HtmlUI.CreateTd(HtmlUI.SubmitButton() + HtmlUI.ResetButton()));
     sr.Append(HtmlUI.TrFinal());
     sr.Append(HtmlUI.TableFinal());
     sr.Append(HtmlUI.FormFinal());
     sr.Append(AdminUI.AdminBoxFinal());
     return sr.ToString();
 }