PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/admin/Comments/Menu.ascx.cs

#
C# | 73 lines | 39 code | 6 blank | 28 comment | 1 complexity | ec05fd77d38f35404d24f28961ca58e2 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. namespace Admin.Comments
  2. {
  3. using System;
  4. using System.Web.UI;
  5. using BlogEngine.Core;
  6. /// <summary>
  7. /// The admin comments menu.
  8. /// </summary>
  9. public partial class Menu : UserControl
  10. {
  11. /// <summary>
  12. /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
  13. /// </summary>
  14. /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
  15. protected override void OnInit(EventArgs e)
  16. {
  17. base.OnInit(e);
  18. }
  19. protected void Page_Load(object sender, EventArgs e)
  20. {
  21. SetCounters();
  22. }
  23. /// <summary>
  24. /// Comment counter
  25. /// </summary>
  26. protected int CommentCount { get; set; }
  27. /// <summary>
  28. /// Pingback/trackback counter
  29. /// </summary>
  30. protected int PingbackCount { get; set; }
  31. /// <summary>
  32. /// Spam counter
  33. /// </summary>
  34. protected int SpamCount { get; set; }
  35. /// <summary>
  36. /// Pending approval
  37. /// </summary>
  38. protected int PendingCount { get; set; }
  39. /// <summary>
  40. /// Indicate that menu item selected
  41. /// </summary>
  42. /// <param name="pg">Page address</param>
  43. /// <returns>CSS class to append for current menu item</returns>
  44. protected string Current(string pg)
  45. {
  46. if (Request.Path.ToLower().Contains(pg.ToLower()))
  47. {
  48. return "class=\"content-box-selected\"";
  49. }
  50. return "";
  51. }
  52. /// <summary>
  53. /// Gets the cookie with visitor information if any is set.
  54. /// Then fills the contact information fields in the form.
  55. /// </summary>
  56. private void SetCounters()
  57. {
  58. foreach (Post p in Post.Posts)
  59. {
  60. PendingCount += p.NotApprovedComments.Count;
  61. PingbackCount += p.Pingbacks.Count;
  62. CommentCount += p.ApprovedComments.Count;
  63. SpamCount += p.SpamComments.Count;
  64. }
  65. }
  66. }
  67. }