void SetupUI() { Selected = null; CommentCollection validComments = extra.GetCommentsFor(entry.EntryId); commentList.Items.Clear(); foreach (Comment c in validComments) { ListViewItem item = new ListViewItem(); item.Text = c.Created.ToString(); item.SubItems.Add(c.Content); item.SubItems.Add(c.Author); item.Tag = c; commentList.Items.Add(item); } }
void ViewingDayChangedUICallback(DayExtra extra) { EndOperation(); Debug.WriteLine("End GetDayExtra"); viewingDayExtra = extra; foreach (Entry entry in viewingDay.Entries) { ListViewItem item = new ListViewItem(); item.Text = entry.Created.ToString("hh:mm tt"); item.SubItems.Add(entry.Categories); item.SubItems.Add(entry.Title); item.SubItems.Add(viewingDayExtra.GetCommentsFor(entry.EntryId).Count.ToString()); item.SubItems.Add(entry.EntryId); item.Tag = entry; entryList.Items.Add(item); } }
private void CommentView_PreRender(object sender, System.EventArgs e) { string entryId = (string)ViewState["entryId"]; EntryIdCache ecache = new EntryIdCache(); ecache.Ensure(data); Control root = comments; DateTime found = new DateTime(); foreach (EntryIdCacheEntry ece in ecache.Entries) { if (ece.EntryId.ToUpper() == entryId) { found = ece.Date; entryId = ece.EntryId; break; } } bool obfuscateEmail = SiteConfig.GetSiteConfig().ObfuscateEmail; DayExtra extra = data.GetDayExtra(found); extra.Load(); foreach (DayEntry day in data.Days) { if (day.Date == found) { day.Load(); foreach (Entry entry in day.Entries) { if (entry.EntryId == entryId) { EntryView entryView = (EntryView)LoadControl("EntryView.ascx"); entryView.Data = data; entryView.Entry = entry; entryView.Extra = extra; comments.Controls.Add(entryView); } } } } commentSpamGuard.Visible = SiteConfig.GetSiteConfig().CommentSpamGuard; if (SiteConfig.GetSiteConfig().CommentSpamGuard) { System.Security.Cryptography.RandomNumberGenerator r = System.Security.Cryptography.RandomNumberGenerator.Create(); byte[] randomData = new byte[4]; r.GetBytes(randomData); int code = 0; for (int i = 0; i < randomData.Length; i++) { code += randomData[i]; } code = code % SiteConfig.GetCommentWords().Length; securityWordImage.ImageUrl = BlogXUtils.RelativeToRoot("verifyimagegen.ashx?code=" + code); ViewState["spamCode"] = code; } foreach (Comment c in extra.GetCommentsFor(entryId)) { SingleCommentView view = (SingleCommentView)LoadControl("SingleCommentView.ascx"); view.Comment = c; view.ObfuscateEmail = obfuscateEmail; root.Controls.Add(view); } }
private void Page_PreRender(object sender, System.EventArgs e) { Control root = this; HtmlGenericControl entryControl = new HtmlGenericControl("div"); entryControl.Attributes["class"] = "entry"; root.Controls.Add(entryControl); HtmlGenericControl entryTitle = new HtmlGenericControl("h3"); entryTitle.Attributes["class"] = "entryTitle"; if (EntryTitleAsLink) { HyperLink entryTitleLink = new HyperLink(); entryTitleLink.NavigateUrl = BlogXUtils.RelativeToRoot("PermaLink.aspx/" + entry.EntryId); entryTitleLink.Text = entry.Title; entryTitle.Controls.Add(entryTitleLink); } else { entryTitle.Controls.Add(new LiteralControl(entry.Title)); } entryControl.Controls.Add(entryTitle); HtmlGenericControl entryBody = new HtmlGenericControl("div"); entryBody.Attributes["class"] = "entryBody"; entryBody.Controls.Add(new LiteralControl(entry.Content)); entryControl.Controls.Add(entryBody); HtmlGenericControl entryFooter = new HtmlGenericControl("p"); entryFooter.Attributes["class"] = "entryFooter"; entryControl.Controls.Add(entryFooter); HyperLink entryDate = new HyperLink(); entryDate.CssClass = "permalink"; entryDate.NavigateUrl = BlogXUtils.RelativeToRoot("PermaLink.aspx/" + entry.EntryId); entryDate.Text = entry.Created.ToString(dateFormat); entryFooter.Controls.Add(entryDate); if (SiteConfig.GetSiteConfig().AllowComments) { entryFooter.Controls.Add(new LiteralControl(" | ")); extra.Load(); CommentCollection entryComments = extra.GetCommentsFor(entry.EntryId); HtmlGenericControl comments = new HtmlGenericControl("span"); comments.Attributes["class"] = "comments"; if (entryComments.Count == 0) { HyperLink comment = new HyperLink(); comment.Text = "Add comment"; comment.NavigateUrl = BlogXUtils.RelativeToRoot("CommentView.aspx/" + entry.EntryId); comments.Controls.Add(comment); } else { HyperLink comment = new HyperLink(); comment.Text = "Comments [" + entryComments.Count + "]"; comment.NavigateUrl = BlogXUtils.RelativeToRoot("CommentView.aspx/" + entry.EntryId); comments.Controls.Add(comment); } entryFooter.Controls.Add(comments); } if (entry.Categories != null && entry.Categories.Length > 0) { entryFooter.Controls.Add(new LiteralControl(" | ")); HtmlGenericControl categories = new HtmlGenericControl("span"); categories.Attributes["class"] = "categories"; foreach (string cat in entry.GetSplitCategories()) { categories.Controls.Add(new LiteralControl(" #")); HyperLink category = new HyperLink(); category.Text = cat; category.NavigateUrl = BlogXUtils.RelativeToRoot("CategoryView.aspx/" + cat); categories.Controls.Add(category); } entryFooter.Controls.Add(categories); } }