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