public CheckEmptyContentResult IsEmpty() { BlogsWidgetSettings widgetSettings = SettingsManager.Instance.LoadSettingsFor <BlogsWidgetSettings>(SecurityContext.CurrentAccount.ID); var engine = BasePage.GetEngine(); var posts = engine.SelectPosts( new PostsQuery() .SetCount(widgetSettings.MaxCountPosts) .NoTags() ); var posts_with_stat = engine.GetPostsCommentsCountAndNew(posts, SecurityContext.CurrentAccount.ID); if (posts_with_stat.Count > 0) { return(CheckEmptyContentResult.NotEmpty); } return(CheckEmptyContentResult.Empty); }
private string RenderLastUpdateContent() { BlogsWidgetSettings widgetSettings = SettingsManager.Instance.LoadSettingsFor <BlogsWidgetSettings>(SecurityContext.CurrentAccount.ID); var engine = BasePage.GetEngine(); var posts = engine.SelectPosts( new PostsQuery() .SetCount(widgetSettings.MaxCountPosts) .NoTags() ); var posts_with_stat = engine.GetPostsCommentsCountAndNew(posts, SecurityContext.CurrentAccount.ID); StringBuilder sb = new StringBuilder(); //posts foreach (var entry in posts_with_stat) { Post post = entry.Value1; int commentsCount = entry.Value2; bool isNewComments = entry.Value3 > 0; sb.Append("<table cellpadding='0' cellspacing='0' border='0'>"); sb.Append("<tr valign='top'>"); sb.Append("<td width='30'>"); sb.Append("<span class='textMediumDescribe'>" + post.Datetime.ToShortDayMonth() + " " + post.Datetime.ToShortTimeString() + "</span>"); sb.Append("</td>"); sb.Append("<td>"); sb.Append("<div style='padding-left:10px;'>"); sb.Append("<div style='margin-bottom:5px;'>"); sb.Append("<a href='" + VirtualPathUtility.ToAbsolute("~/products/community/modules/blogs/viewblog.aspx") + "?blogid=" + post.ID + "'>" + post.Title.HtmlEncode() + "</a>"); if (commentsCount > 0) { if (isNewComments) { sb.AppendFormat("<span style='margin-left:7px;' class='errorText'>({0})</span>", commentsCount); } else { sb.AppendFormat("<span style='margin-left:7px;' class='describeText'>({0})</span>", commentsCount); } } sb.Append("</div>"); sb.Append("<div style='margin-bottom:5px;'>"); sb.Append(HtmlUtility.GetText(post.Content, 120)); sb.Append("</div>"); sb.Append("<div style='margin-bottom:17px;'>"); sb.Append("<span class='textBigDescribe'>" + ASC.Blogs.Core.Resources.BlogsResource.PostedTitle + ":</span> " + CoreContext.UserManager.GetUsers(post.UserID).RenderProfileLink(ASC.Web.Community.Product.CommunityProduct.ID)); sb.Append("</div>"); sb.Append("</div>"); sb.Append("</td>"); sb.Append("</tr>"); sb.Append("</table>"); } if (posts_with_stat.Count > 0) { sb.AppendFormat("<div style='margin-top: 10px;'><a href='{0}'>{1}</a></div>", ASC.Blogs.Core.Constants.DefaultPageUrl, ASC.Blogs.Core.Resources.BlogsResource.AllBlogs ); } else { if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(CoreContext.UserManager.GetUsers( SecurityContext.CurrentAccount.ID)), ASC.Blogs.Core.Constants.Action_AddPost)) { sb.Append("<div class=\"empty-widget\" style=\"padding:40px; text-align: center;\">" + String.Format(ASC.Blogs.Core.Resources.BlogsResource.NoBlogsWidgetTitle, string.Format("<div style=\"padding-top:3px;\"><a class=\"promoAction\" href=\"{0}\">", VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath + "addblog.aspx")), "</a></div>") + "</div>"); } else { sb.Append("<div class==\"empty-widget\" style=\"padding:40px; text-align: center;\">" + ASC.Blogs.Core.Resources.BlogsResource.NoBlogsWidgetMessage + "</div>"); } } return(sb.ToString()); }