protected void Page_Load(object sender, EventArgs e) { var settings = ForumManager.GetSettings(SettingsID); Topics = new List<Topic>(); if (ThreadID == 0) Response.Redirect(settings.StartPageAbsolutePath); int currentPageNumber = 0; if (!String.IsNullOrEmpty(Request["p"])) { try { currentPageNumber = Convert.ToInt32(Request["p"]); } catch { currentPageNumber = 0; } } if (currentPageNumber <= 0) currentPageNumber = 1; int topicCountInThread = 0; Topics = ForumDataProvider.GetTopics(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, ThreadID, currentPageNumber, settings.TopicCountOnPage, out topicCountInThread); ForumDataProvider.SetThreadVisit(TenantProvider.CurrentTenantID, ThreadID); int i = 0; foreach (Topic topic in Topics) { TopicControl topicControl = (TopicControl)LoadControl(settings.UserControlsVirtualPath+"/TopicControl.ascx"); topicControl.Topic = topic; topicControl.SettingsID = SettingsID; topicControl.IsEven = (i % 2 == 0); this.topicListHolder.Controls.Add(topicControl); i++; } PageNavigator pageNavigator = new PageNavigator() { PageUrl = settings.LinkProvider.TopicList(ThreadID), CurrentPageNumber = currentPageNumber, EntryCountOnPage = settings.TopicCountOnPage, VisiblePageCount = 5, EntryCount = topicCountInThread }; bottomPageNavigatorHolder.Controls.Add(pageNavigator); }
protected void Page_Load(object sender, EventArgs e) { _settings = ForumManager.GetSettings(SettingsID); _forumManager = _settings.ForumManager; if (this.Topic == null) Response.Redirect(_settings.StartPageAbsolutePath); if ((new Thread() { ID = Topic.ThreadID }).Visible == false) Response.Redirect(_settings.StartPageAbsolutePath); int currentPageNumber = 0; if (!String.IsNullOrEmpty(Request["p"])) { try { currentPageNumber = Convert.ToInt32(Request["p"]); } catch { currentPageNumber = 0; } } if (currentPageNumber <= 0) currentPageNumber = 1; int postCountInTopic = 0; var posts = ForumDataProvider.GetPosts(TenantProvider.CurrentTenantID, Topic.ID, currentPageNumber, _settings.PostCountOnPage, out postCountInTopic); PageNavigator pageNavigator = new PageNavigator() { PageUrl = _settings.LinkProvider.PostList(Topic.ID), CurrentPageNumber = currentPageNumber, EntryCountOnPage = _settings.PostCountOnPage, VisiblePageCount = 5, EntryCount = postCountInTopic }; bottomPageNavigatorHolder.Controls.Add(pageNavigator); int i = 0; foreach (Post post in posts) { PostControl postControl = (PostControl)LoadControl(_settings.UserControlsVirtualPath+"/PostControl.ascx"); postControl.Post = post; postControl.IsEven = (i%2==0); postControl.SettingsID = SettingsID; postControl.CurrentPageNumber = currentPageNumber; postControl.PostsCount = Topic.PostCount; this.postListHolder.Controls.Add(postControl); i++; } ForumDataProvider.SetTopicVisit(Topic); if (Topic.Type == TopicType.Poll) { var q = ForumDataProvider.GetPollByID(TenantProvider.CurrentTenantID, Topic.QuestionID); if(q==null) return; var isVote = ForumDataProvider.IsUserVote(TenantProvider.CurrentTenantID, q.ID, SecurityContext.CurrentAccount.ID); var pollForm = new PollForm(); pollForm.VoteHandlerType = typeof(PollVoteHandler); pollForm.Answered =isVote ||Topic.Closed || !_forumManager.ValidateAccessSecurityAction(ForumAction.PollVote, q) || ASC.Core.SecurityContext.DemoMode || (SetupInfo.WorkMode == WorkMode.Promo); pollForm.Name = q.Name; pollForm.PollID = q.ID.ToString(); pollForm.Singleton = (q.Type == QuestionType.OneAnswer); pollForm.AdditionalParams = _settings.ID.ToString() + "," + q.ID.ToString(); foreach (var variant in q.AnswerVariants) { pollForm.AnswerVariants.Add(new PollForm.AnswerViarint() { ID = variant.ID.ToString(), Name = variant.Name, VoteCount = variant.AnswerCount }); } pollHolder.Controls.Add(new Literal() { Text = "<div style='position:relative; padding-left:20px; margin-bottom:15px;'>" }); pollHolder.Controls.Add(pollForm); pollHolder.Controls.Add(new Literal() { Text = "</div>" }); } }