public static string GenerateThreadPage(int id) { StringBuilder pageHTML = new StringBuilder(BoardCommon.GetGenericPageHTML()); pageHTML.Replace("{lang:postaction}", Lang.reply); pageHTML.Replace("{DesktopReturnHTML}", TemplateProvider.html_desktop_return); pageHTML.Replace("{MobileReturnHTML}", TemplateProvider.html_mobile_return); pageHTML.Replace("{PostFormMode}", "reply"); pageHTML.Replace("{PostFormTID}", id.ToString()); pageHTML.Replace("{AddNewFilesButtonHTML}", TemplateProvider.html_add_new_files); if (Settings.ApplicationSettings.EnableCaptcha) { pageHTML.Replace("{captcha}", BoardCommon.GetCaptchaFullPageBody()); } else { pageHTML.Replace("{captcha}", ""); } pageHTML.Replace("{PagesList}", ""); pageHTML.Replace("{DocumentBody}", get_thread_body(id)); return(pageHTML.ToString()); }
public static string GenerateIndexPage(HttpContext context, bool isArchive) { StringBuilder pageHTML = new StringBuilder(BoardCommon.GetGenericPageHTML()); pageHTML.Replace("{PostFormMode}", "thread"); pageHTML.Replace("{PostFormTID}", "0"); pageHTML.Replace("{AddNewFilesButtonHTML}", ""); pageHTML.Replace("{DesktopReturnHTML}", ""); pageHTML.Replace("{MobileReturnHTML}", ""); pageHTML.Replace("{lang:postaction}", Lang.newthread); if (Settings.ApplicationSettings.EnableCaptcha) { pageHTML.Replace("{captcha}", BoardCommon.GetCaptchaFullPageBody()); } else { pageHTML.Replace("{captcha}", ""); } int page = 1; if (!string.IsNullOrEmpty(context.Request["pn"])) { page = Convert.ToInt32(context.Request["pn"]); } if (page < 0) { page = 1; } int thread_count = 0; using (DbConnection dc = Database.DatabaseEngine.GetDBConnection()) { dc.Open(); thread_count = BoardCommon.GetThreadsCount(isArchive, dc); int[] threads = BoardCommon.GetPageInts(page, isArchive, dc); StringBuilder documentBody = new StringBuilder(); foreach (int threadID in threads) { documentBody.Append(GetIndexThreadHTML(threadID, dc)); } pageHTML.Replace("{DocumentBody}", documentBody.ToString()); } pageHTML.Replace("{PagesList}", get_pagelist(thread_count, page)); return(pageHTML.ToString()); }
private static string generate_thread_body(int id, DbConnection con) { WPost[] posts = BoardCommon.GetThreadData(id, con); StringBuilder body = new StringBuilder(); body.Append(string.Format("<div class=\"thread\" id=\"t{0}\">", id)); //op post body.Append(posts[0].ToString()); body.Replace("{op:replycount}", ""); for (int i = 1; i < posts.Length; i++) { body.Append(posts[i].ToString()); } body.Append("</div><hr/>"); return(body.ToString()); }
private static string generate_index_thread_html(int id, DbConnection con) { WPost OP = BoardCommon.GetPostData(id, con); if (OP == null) { return(""); } else { List <WPost> posts = new List <WPost>(); posts.Add(OP); ThreadReplies tr = BoardCommon.GetThreadReplies(OP, con); if (Settings.ApplicationSettings.TrailPostsCount > 0 && tr.TotalReplies > 0) { posts.AddRange(BoardCommon.GetLastReplies(OP, con)); } StringBuilder thread = new StringBuilder(TemplateProvider.Thread); thread.Replace("{id}", posts[0].PostID.ToString()); thread.Replace("{OP}", posts[0].ToString()); StringBuilder replies = new StringBuilder(); int with_image = 0; for (int i = 1; i < posts.Count; i++) { replies.Append(posts[i].ToString()); if (posts[i].FileCount > 0) { with_image++; } } if (tr.TotalReplies > 0) { thread.Replace("{op:replycount}", string.Format("(<b>{0} {1}</b>)", tr.TotalReplies, Lang.replies)); int omitted_text_post_count = tr.TextReplies - (posts.Count - 1 - with_image); int omitted_image_post_count = tr.ImageReplies - with_image; string summary = ""; if (omitted_image_post_count > 0 & omitted_text_post_count <= 0) { //image only. summary = Lang.summaryIonly; } else if (omitted_text_post_count > 0 & omitted_image_post_count <= 0) { //text only summary = Lang.summaryPonly; } else if (omitted_image_post_count > 0 & omitted_text_post_count > 0) { //image and text summary = Lang.summaryPandI; } summary = summary.Replace("{i}", omitted_image_post_count.ToString()).Replace("{p}", omitted_text_post_count.ToString()); thread.Replace("{desktop:summary}", string.Format("<span class=\"summary desktop\">{0}</span>", summary)); thread.Replace("{mobile:summary}", string.Format("<span class=\"info\">{0}</span><br />", summary)); } else { thread.Replace("{op:replycount}", ""); thread.Replace("{desktop:summary}", ""); thread.Replace("{mobile:summary}", ""); } thread.Replace("{postlink}", string.Format("{0}{1}.aspx?id={2}", Settings.Paths.WebRoot, posts[0].IsArchived ? "archive" : "default", posts[0].PostID)); thread.Replace("{Replies}", replies.ToString()); return(thread.ToString()); } }