public IEnumerable <ForumTopicWrapper> GetLastTopics() { var result = ForumDataProvider.GetLastUpdateTopics(TenantId, (int)_context.StartIndex, (int)_context.Count); _context.SetDataPaginated(); return(result.Select(x => new ForumTopicWrapper(x)).ToSmartList()); }
public CheckEmptyContentResult IsEmpty() { ForumLastUpdatesWidgetSettings widgetSettings = SettingsManager.Instance.LoadSettingsFor <ForumLastUpdatesWidgetSettings>(SecurityContext.CurrentAccount.ID); var topicList = ForumDataProvider.GetLastUpdateTopics(TenantProvider.CurrentTenantID, widgetSettings.MaxTopicCount); if (topicList.Count > 0) { return(CheckEmptyContentResult.NotEmpty); } return(CheckEmptyContentResult.Empty); }
public void InitView() { _settings = Community.Forum.ForumManager.Settings; TopicList = ForumDataProvider.GetLastUpdateTopics(TenantProvider.CurrentTenantID, MaxTopicCount); }
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer) { ForumLastUpdatesWidgetSettings widgetSettings = SettingsManager.Instance.LoadSettingsFor <ForumLastUpdatesWidgetSettings>(SecurityContext.CurrentAccount.ID); var topicList = ForumDataProvider.GetLastUpdateTopics(TenantProvider.CurrentTenantID, widgetSettings.MaxTopicCount); StringBuilder sb = new StringBuilder(); foreach (Topic topic in topicList) { if (topic.RecentPostID != 0) { sb.Append("<div class='clearFix' style='margin-bottom:20px;'>"); sb.Append("<table cellspacing='0' cellpadding='0' border='0'><tr valign='top'>"); //date sb.Append("<td style='width:30px; text-align:left;'>"); sb.Append(DateTimeService.DateTime2StringWidgetStyle(topic.RecentPostCreateDate)); sb.Append("</td>"); //message sb.Append("<td style='padding-left:10px;'>"); string recentPostURL = VirtualPathUtility.ToAbsolute(ForumManager.BaseVirtualPath + "/posts.aspx") + "?t=" + topic.ID; int pageNum = Convert.ToInt32(Math.Ceiling(topic.PostCount / (ForumManager.Settings.PostCountOnPage * 1.0))); if (pageNum <= 0) { pageNum = 1; } if (topic.RecentPostID != 0) { recentPostURL = VirtualPathUtility.ToAbsolute(ForumManager.BaseVirtualPath + "/posts.aspx") + "?t=" + topic.ID.ToString() + "&p=" + pageNum.ToString() + "#" + topic.RecentPostID.ToString(); } string message = topic.RecentPostText; if (topic.RecentPostFormatter == PostTextFormatter.BBCode) { message = new ASC.Web.Controls.BBCodeParser.Parser(CommonControlsConfigurer.TextConfig).Parse(topic.RecentPostText); } if (widgetSettings.IsCutLongMessage) { message = HtmlUtility.GetText(message, 120, true); } else { message = HtmlUtility.GetText(message, true); } //topic sb.Append("<div>"); sb.Append("<a href='" + recentPostURL + "'>" + HttpUtility.HtmlEncode(topic.Title) + "</a>"); if (topic.IsNew()) { sb.Append("<span style='margin-left:7px;' class='errorText'>(" + topic.PostCount + ")</span>"); } else { sb.Append("<span style='margin-left:7px;' class='describeText'>(" + topic.PostCount + ")</span>"); } sb.Append("</div>"); //thread //post sb.Append("<div style='margin-top:5px;'>"); sb.Append(message); sb.Append("</div>"); //who sb.Append("<div style='margin-top:5px;'>"); sb.Append("<span class='textBigDescribe' style='margin-right:5px;'>" + Resources.ForumResource.PostedBy + ":</span>"); sb.Append(topic.RecentPostAuthor.RenderProfileLink(CommunityProduct.ID)); sb.Append("</div>"); sb.Append("</td>"); sb.Append("</tr></table>"); sb.Append("</div>"); } } if (topicList.Count > 0) { sb.Append("<div style='margin-top:10px;'>"); sb.Append("<a href=\"" + VirtualPathUtility.ToAbsolute(ForumManager.BaseVirtualPath + "/default.aspx") + "\">" + Resources.ForumResource.ForumsBreadCrumbs + "</a>"); sb.Append("</div>"); } else { sb.Append("<div class=\"empty-widget\" style='text-align:center; padding:40px 0px;'>"); if (ForumManager.Instance.ValidateAccessSecurityAction(ForumAction.GetAccessForumEditor, null)) { sb.AppendFormat( Resources.ForumResource.ForumNotCreatedWidgetMessageForAdmin, string.Format("<div style=\"padding-top:3px;\"><a href=\"{0}\">", VirtualPathUtility.ToAbsolute(ForumManager.BaseVirtualPath + "/managementcenter.aspx")), "</a></div>"); } else { sb.Append(Resources.ForumResource.ForumNotCreatedWidgetMessage); } sb.Append("</div>"); } writer.Write(sb.ToString()); }