private void PopulateControls() { if (forum == null) { return; } //TODO: need to look into this: // http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html //http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#sequential-link-types string pageUrl; if (ForumConfiguration.CombineUrlParams) { pageUrl = SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&f=" + forum.ItemId.ToInvariantString() + "~{0}"; } else { pageUrl = SiteRoot + "/Forums/ForumView.aspx?" + "ItemID=" + forum.ItemId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "&pagenumber={0}"; } pgrTop.PageURLFormat = pageUrl; pgrTop.ShowFirstLast = true; pgrTop.CurrentIndex = pageNumber; pgrTop.PageSize = forum.ThreadsPerPage; pgrTop.PageCount = forum.TotalPages; pgrTop.Visible = (pgrTop.PageCount > 1); pgrBottom.PageURLFormat = pageUrl; pgrBottom.ShowFirstLast = true; pgrBottom.CurrentIndex = pageNumber; pgrBottom.PageSize = forum.ThreadsPerPage; pgrBottom.PageCount = forum.TotalPages; pgrBottom.Visible = (pgrBottom.PageCount > 1); lnkNewThread.HRef = SiteRoot + "/Forums/EditPost.aspx?forumid=" + ItemId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "&mid=" + ModuleId.ToInvariantString(); lnkNewThreadBottom.HRef = lnkNewThread.HRef; lnkNewThread.Visible = WebUser.IsInRoles(forum.RolesThatCanPost) && !forum.Closed; lnkNewThreadBottom.Visible = lnkNewThread.Visible; lnkLogin.Visible = !lnkNewThread.Visible && !Request.IsAuthenticated; using (IDataReader reader = forum.GetThreads(pageNumber)) { rptForums.DataSource = reader; #if MONO this.rptForums.DataBind(); #else this.DataBind(); #endif } }
private void PopulateControls() { if (forum == null) { return; } if (thread == null) { return; } if ((thread.TotalReplies + 1) == forum.PostsPerPage) { nextPageNumber = PageNumber + 1; } else { nextPageNumber = PageNumber; } string pageUrl; string viewAllUrl = string.Empty; if (ForumConfiguration.CombineUrlParams) { pageUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + PageId.ToInvariantString() + "&t=" + threadId.ToInvariantString() + "~{0}"; viewAllUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + PageId.ToInvariantString() + "&t=" + threadId.ToInvariantString() + "~-1"; } else { pageUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + PageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&ItemID=" + ItemId.ToInvariantString() + "&thread=" + threadId.ToInvariantString() + "&pagenumber={0}"; } pgrTop.PageURLFormat = pageUrl; pgrTop.ShowFirstLast = true; pgrTop.CurrentIndex = PageNumber; pgrTop.PageSize = forum.ThreadsPerPage; pgrTop.PageCount = thread.TotalPages; pgrTop.Visible = (pgrTop.PageCount > 1); pgrBottom.PageURLFormat = pageUrl; pgrBottom.ShowFirstLast = true; pgrBottom.CurrentIndex = PageNumber; pgrBottom.PageSize = forum.ThreadsPerPage; pgrBottom.PageCount = thread.TotalPages; pgrBottom.Visible = (pgrBottom.PageCount > 1); if (ForumConfiguration.ShowPagerViewAllLink) { pgrTop.ViewAllUrl = viewAllUrl; pgrBottom.ViewAllUrl = viewAllUrl; } lnkNewPost.InnerHtml = ForumResources.ForumThreadViewReplyLabel; lnkNewPost.HRef = SiteRoot + "/Forums/EditPost.aspx?" + "thread=" + threadId.ToString() + "&forumid=" + forum.ItemId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&pageid=" + PageId.ToString() + "&pagenumber=" + nextPageNumber.ToInvariantString(); lnkNewPost.Visible = WebUser.IsInRoles(forum.RolesThatCanPost) && !forum.Closed; lnkNewPostBottom.Visible = lnkNewPost.Visible; lnkNewPostBottom.InnerHtml = ForumResources.ForumThreadViewReplyLabel; lnkNewPostBottom.HRef = lnkNewPost.HRef; lnkLogin.Visible = !lnkNewPost.Visible && !Request.IsAuthenticated; lnkLoginBottom.Visible = lnkLogin.Visible; if ((thread.IsLocked || forum.Closed || thread.IsClosed(config.CloseThreadsOlderThanDays)) && (!isEditable)) { lnkNewPost.Visible = false; lnkNewPostBottom.Visible = false; lblClosedTop.Visible = true; lblClosedBottom.Visible = true; } //lnkLogin.NavigateUrl = SiteRoot + "/Secure/Login.aspx?returnurl=" + Server.UrlEncode(Request.RawUrl); lnkLogin.Text = ForumResources.ForumsLoginRequiredLink; //lnkLoginBottom.NavigateUrl = SiteRoot + "/Secure/Login.aspx?returnurl=" + Server.UrlEncode(Request.RawUrl); lnkLoginBottom.Text = ForumResources.ForumsLoginRequiredLink; if (useReverseSort) { using (IDataReader reader = thread.GetPostsReverseSorted()) { this.rptMessages.DataSource = reader; this.rptMessages.DataBind(); } pgrTop.Visible = false; pgrBottom.Visible = false; lnkNewPost.Visible = false; lnkNewPostBottom.Visible = false; } else { if (PageNumber == -1) { using (IDataReader reader = thread.GetPosts()) { rptMessages.DataSource = reader; rptMessages.DataBind(); } if (thread.TotalPages <= 1) { pgrTop.Visible = false; pgrBottom.Visible = false; } } else { using (IDataReader reader = thread.GetPosts(PageNumber)) { rptMessages.DataSource = reader; rptMessages.DataBind(); } } if ( (rptMessages.Items.Count == 0) && (ItemId > -1) ) { // when the last post in a thread is deleted // the ForumPostEditPage redirects to this page // but it will hit this code and go back to the forum instead of showing // the empty thread string redirectUrl; if (ForumConfiguration.CombineUrlParams) { if (pageNumber > 1) { // try going back to page 1 redirectUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + PageId.ToInvariantString() + "&t=" + threadId.ToInvariantString() + "~1"; } else { redirectUrl = SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&f=" + ItemId.ToInvariantString() + "~1"; } } else { redirectUrl = SiteRoot + "/Forums/ForumView.aspx?" + "ItemID=" + ItemId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); } WebUtils.SetupRedirect(this, redirectUrl); } else { thread.UpdateThreadViewStats(); } } }
private void LoadSettings() { if (siteSettings == null) { return; } TimeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); showUserRevenue = (WebConfigSettings.ShowRevenueInForums && isCommerceReportViewer); currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code); filterContentFromTrustedUsers = ForumConfiguration.FilterContentFromTrustedUsers; if (ForumConfiguration.AllowExternalImages) { allowedImageUrlRegexPattern = SecurityHelper.RegexAnyImageUrlPatern; } IsModerator = isEditable; if (forum != null) { if (WebUser.IsInRoles(forum.RolesThatCanModerate)) { IsModerator = true; } } switch (siteSettings.AvatarSystem) { case "gravatar": allowGravatars = true; disableAvatars = false; break; case "internal": allowGravatars = false; disableAvatars = false; break; case "none": default: allowGravatars = false; disableAvatars = true; break; } if (displaySettings.HideAvatars) { allowGravatars = false; disableAvatars = true; } notificationUrl = SiteRoot + "/Forums/EditSubscriptions.aspx?mid=" + moduleId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "#forum" + ItemId.ToInvariantString(); pnlNotify.Visible = (!isSubscribedToForum) && !displaySettings.HideNotificationLinkOnPostList; if (!Request.IsAuthenticated) { pnlNotify.Visible = false; } if (WebConfigSettings.LoginPageRelativeUrl.Length > 0) { lnkLogin.NavigateUrl = SiteRoot + WebConfigSettings.LoginPageRelativeUrl + "?returnurl=" + Server.UrlEncode(Request.RawUrl); lnkLoginBottom.NavigateUrl = SiteRoot + WebConfigSettings.LoginPageRelativeUrl + "?returnurl=" + Server.UrlEncode(Request.RawUrl); } else { lnkLogin.NavigateUrl = SiteRoot + "/Secure/Login.aspx?returnurl=" + Server.UrlEncode(Request.RawUrl); lnkLoginBottom.NavigateUrl = SiteRoot + "/Secure/Login.aspx?returnurl=" + Server.UrlEncode(Request.RawUrl); } }