protected static string TopicPageLinks(object replyCount, object topicId) { string retVal = ""; if (!Config.ShowPaging) { return(retVal); } if ((int)replyCount > Config.TopicPageSize) { int pageNum = (int)replyCount / Config.TopicPageSize; int rem = (int)replyCount % Config.TopicPageSize; if (rem > 0) { pageNum += 1; } retVal = " ... "; for (int x = Math.Max(2, SnitzCookie.LastTopicPage((int)topicId) + 1); x < pageNum + 1; x++) { retVal += "<a href='/Content/Forums/topic.aspx?TOPIC=" + topicId + "&whichpage=" + x + "'><span class='topicPageLnk' >" + x + "</span></a> "; } } return(retVal); }
protected void Page_Load(object sender, EventArgs e) { if (CurrentPage == -1) { CurrentPage = 0; } if (Request.Form["__EVENTTARGET"] != null) { //let's check what async call posted back and see if we need to refresh the page string target = Request.Form["__EVENTTARGET"]; var listOfStrings = new List <string> { "TopicSend", "DeleteTopic", "DeleteReply" }; bool refreshAfterPostback = listOfStrings.Any(target.EndsWith); if (refreshAfterPostback) { ReplyPager.CurrentIndex = CurrentPage; } } if (!Page.IsPostBack) { TopicInfo topic = _topic; string session = "FORUM" + topic.ForumId; if (IsAuthenticated) { //do we have access to this forum if (!Forums.IsUserInForumRole(Member.Username, topic.Forum.Id)) { if (Session[session] == null || Session[session].ToString() != "true") { if (topic.Forum.Password != null && !String.IsNullOrEmpty(topic.Forum.Password.Trim())) { if (Session[session] == null || Session[session].ToString() == "") { Response.Redirect("~/Content/Forums/forum.aspx?FORUM=" + topic.ForumId); } else { if (Session[session].ToString() != "true") { throw new SecurityException("You are not authorised to view this forum"); } } } } if (topic.Forum.Roles.Contains("All") || topic.Forum.Roles.Count == 0) { if (String.IsNullOrEmpty(topic.Forum.Password)) { WriteShareItScriptTags(); } } } else { Session[session] = "true"; } } else if (topic.Forum.Roles.Contains("All") || topic.Forum.Roles.Count == 0) { Session[session] = "true"; WriteShareItScriptTags(); } else if (topic.Forum.Roles.Count > 0 && !topic.Forum.Roles.Contains("All")) { if (Session[session] == null || Session[session].ToString() != "true") { throw new SecurityException("You must be logged in to view this forum"); } } Topics.UpdateViewCount(_topic.Id); int pagejump = 0; if (Request.QueryString["LastVisit"] != null) { pagejump = SnitzCookie.LastTopicPage(topic.Id); } if (pagejump == 0) { if ((Request.Params["whichpage"] != null)) { pagejump = Int32.Parse(Request.Params["whichpage"]); } } if (pagejump != 0) { if (pagejump == -1) { //jump to last page int pagenum = topic.ReplyCount / Config.TopicPageSize; if (topic.ReplyCount % Config.TopicPageSize == 0) { if (topic.ReplyCount > 0) { pagenum -= 1; } } CurrentPage = pagenum; ReplyPager.CurrentIndex = pagenum; } else { int pagenum = pagejump - 1; CurrentPage = pagenum; ReplyPager.CurrentIndex = pagenum; } } else { ReplyPager.CurrentIndex = CurrentPage; } SnitzCookie.TrackIt(_topic.Id, CurrentPage); } //TopicView.Visible = ReplyPager.CurrentIndex == 0; if (Request.Params["reply"] != null) { string reply = Request.Params["reply"]; if (reply != "0") { JumpToReply(reply); } } }