protected void Page_Load(object sender, EventArgs e)
        {            
            var settings = ForumManager.GetSettings(SettingsID);
            PageSize = string.IsNullOrEmpty(Request["size"]) ? 20 : Convert.ToInt32(Request["size"]);
            //var pageSize = PageSize;            
            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, PageSize, 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++;
            }
            PageSize = string.IsNullOrEmpty(Request["size"]) ? 20 : Convert.ToInt32(Request["size"]);
            var pageSize = PageSize;            

            PageNavigator pageNavigator = new PageNavigator()
            {
                PageUrl = string.Format(
                        CultureInfo.CurrentCulture,
                        "{0}?&f={1}&size={2}",
                        VirtualPathUtility.ToAbsolute("~/products/community/modules/forum/topics.aspx"),
                        ThreadID,
                        pageSize
                        ),
                //settings.LinkProvider.TopicList(ThreadID),
                CurrentPageNumber = currentPageNumber,
                EntryCountOnPage = pageSize, //settings.TopicCountOnPage,
                VisiblePageCount = 5,
                EntryCount = topicCountInThread
            };
            TopicPagesCount = pageNavigator.EntryCount;
            var pageCount = (int)(TopicPagesCount / pageSize + 1);
            if (pageCount < pageNavigator.CurrentPageNumber)
            {
                pageNavigator.CurrentPageNumber = pageCount;
            }
            
            bottomPageNavigatorHolder.Controls.Add(pageNavigator);
            InitScripts();
        }
        protected void Page_Load(object sender, EventArgs e)
        {            
            _settings = ForumManager.GetSettings(SettingsID);
            _forumManager = _settings.ForumManager;
            PostPageSize = string.IsNullOrEmpty(Request["size"]) ? 20 : Convert.ToInt32(Request["size"]);

            if (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;
            var posts = ForumDataProvider.GetPosts(TenantProvider.CurrentTenantID, Topic.ID, currentPageNumber, PostPageSize, out postCountInTopic);
            
            var postId = 0;
            if (!string.IsNullOrEmpty(Request["post"]))
            {
                try
                {
                    postId = Convert.ToInt32(Request["post"]);
                }
                catch { postId = 0; }
            }

            if (postId != 0)
            {
                var allposts = ForumDataProvider.GetPostIDs(TenantProvider.CurrentTenantID, Topic.ID);
                var idx = -1;
                for (var j = 0; j < allposts.Count; j++)
                {
                    if (allposts[j] != postId) continue;

                    idx = j;
                    break;
                }
                if (idx != -1)
                {
                    var page = idx / 20 + 1;
                    Response.Redirect("posts.aspx?t=" + Topic.ID + "&size=20&p=" + page + "#" + postId);
                }
            }

            PostPagesCount = postCountInTopic;
            var pageSize = PostPageSize;
            var pageNavigator = new PageNavigator
                                    {
                                        PageUrl = string.Format(
                                            CultureInfo.CurrentCulture,
                                            "{0}?&t={1}&size={2}",
                                            VirtualPathUtility.ToAbsolute("~/products/community/modules/forum/posts.aspx"),
                                            Topic.ID,
                                            pageSize
                                            ),
                                        //_settings.LinkProvider.PostList(Topic.ID),
                                        CurrentPageNumber = currentPageNumber,
                                        EntryCountOnPage = pageSize,
                                        VisiblePageCount = 5,
                                        EntryCount = postCountInTopic
                                    };
                     

            bottomPageNavigatorHolder.Controls.Add(pageNavigator);

            var i = 0;
            foreach (var post in posts)
            {
                var 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;
                postListHolder.Controls.Add(postControl);
                i++;
            }

            ForumDataProvider.SetTopicVisit(Topic);
            InitScripts();
            if (Topic.Type != TopicType.Poll) return;
            
            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
                               {
                                   VoteHandlerType = typeof (PollVoteHandler),
                                   Answered = isVote || Topic.Closed || !_forumManager.ValidateAccessSecurityAction(ForumAction.PollVote, q),
                                   Name = q.Name,
                                   PollID = q.ID.ToString(),
                                   Singleton = (q.Type == QuestionType.OneAnswer),
                                   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>"});
            
        }
        private void SetBookmarkingPagination()
        {
            var pageNavigator = new PageNavigator();

            _serviceHelper.InitPageNavigator(pageNavigator, BookmarkPageCounter);

            itemCounter = pageNavigator.EntryCount;

            BookmarkingPaginationContainer.Controls.Add(pageNavigator);
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ForumManager.Instance.SetCurrentPage(ForumPage.Search);

            int currentPageNumber;
            if (!int.TryParse(Request["p"], out currentPageNumber))
                currentPageNumber = 1;

            if (currentPageNumber <= 0)
                currentPageNumber = 1;

            var findTopicList = new List<Topic>();
            var topicCount = 0;

            if (!String.IsNullOrEmpty(Request["uid"]))
            {
                try
                {
                    _userID = new Guid(Request["uid"]);
                }
                catch
                {
                    _userID = Guid.Empty;
                }

                if (_userID != Guid.Empty)
                {
                    findTopicList = ForumDataProvider.SearchTopicsByUser(TenantProvider.CurrentTenantID, _userID, currentPageNumber, ForumManager.Settings.TopicCountOnPage, out topicCount);
                }
            }

            if (findTopicList.Count > 0)
            {
                _isFind = true;

                var i = 0;
                foreach (var topic in findTopicList)
                {
                    var topicControl = (TopicControl)LoadControl(ForumManager.Settings.UserControlsVirtualPath + "/TopicControl.ascx");
                    topicControl.SettingsID = ForumManager.Settings.ID;
                    topicControl.Topic = topic;
                    topicControl.IsShowThreadName = true;
                    topicControl.IsEven = (i%2 == 0);
                    topicListHolder.Controls.Add(topicControl);
                    i++;
                }

                #region navigators

                var pageNavigator = new PageNavigator
                    {
                        CurrentPageNumber = currentPageNumber,
                        EntryCountOnPage = ForumManager.Settings.TopicCountOnPage,
                        VisiblePageCount = 5,
                        EntryCount = topicCount,
                        PageUrl = "usertopics.aspx?uid=" + _userID.ToString()
                    };

                bottomPageNavigatorHolder.Controls.Add(pageNavigator);

                #endregion
            }
            else
            {
                var emptyScreenControl = new EmptyScreenControl
                    {
                        ImgSrc = WebImageSupplier.GetAbsoluteWebPath("forums_icon.png", ForumManager.Settings.ModuleID),
                        Header = Resources.ForumResource.EmptyScreenSearchCaption,
                        Describe = Resources.ForumResource.EmptyScreenSearchText,
                    };

                topicListHolder.Controls.Add(emptyScreenControl);
            }

            //bread crumbs
            (Master as ForumMasterPage).CurrentPageCaption = CoreContext.UserManager.GetUsers(_userID).DisplayUserName(false);

            Title = HeaderStringHelper.GetPageTitle((Master as ForumMasterPage).CurrentPageCaption);
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ForumManager.Instance.SetCurrentPage(ForumPage.Search);

            var currentPageNumber = 0;
            if (!String.IsNullOrEmpty(Request["p"]))
            {
                try
                {
                    currentPageNumber = Convert.ToInt32(Request["p"]);
                }
                catch
                {
                    currentPageNumber = 0;
                }
            }
            if (currentPageNumber <= 0)
                currentPageNumber = 1;

            var findTopicList = new List<Topic>();
            var topicCount = 0;

            var searchText = "";
            _tagID = 0;
            _isFindByTag = false;

            var tagName = "";

            if (!String.IsNullOrEmpty(Request["tag"]))
            {
                _isFindByTag = true;
                try
                {
                    _tagID = Convert.ToInt32(Request["tag"]);
                }
                catch
                {
                    _tagID = 0;
                }

                findTopicList = ForumDataProvider.SearchTopicsByTag(TenantProvider.CurrentTenantID, _tagID, currentPageNumber, ForumManager.Settings.TopicCountOnPage, out topicCount);

            }
            else if (!String.IsNullOrEmpty(Request["search"]))
            {
                searchText = Request["search"];
                findTopicList = ForumDataProvider.SearchTopicsByText(TenantProvider.CurrentTenantID, searchText, currentPageNumber, ForumManager.Settings.TopicCountOnPage, out topicCount);
            }

            if (findTopicList.Count > 0)
            {
                _isFind = true;

                var i = 0;
                foreach (var topic in findTopicList)
                {
                    if (i == 0)
                    {
                        foreach (var tag in topic.Tags)
                        {
                            if (tag.ID == _tagID)
                            {
                                tagName = tag.Name;
                                break;
                            }
                        }
                    }

                    var topicControl = (TopicControl)LoadControl(ForumManager.Settings.UserControlsVirtualPath + "/TopicControl.ascx");
                    topicControl.SettingsID = ForumManager.Settings.ID;
                    topicControl.Topic = topic;
                    topicControl.IsShowThreadName = true;
                    topicControl.IsEven = (i%2 == 0);
                    topicListHolder.Controls.Add(topicControl);
                    i++;
                }

                var pageNavigator = new PageNavigator
                    {
                        CurrentPageNumber = currentPageNumber,
                        EntryCountOnPage = ForumManager.Settings.TopicCountOnPage,
                        VisiblePageCount = 5,
                        EntryCount = topicCount
                    };
                if (_isFindByTag)
                    pageNavigator.PageUrl = _isFindByTag
                                                ? "search.aspx?tag=" + _tagID.ToString()
                                                : "search.aspx?search=" + HttpUtility.UrlEncode(searchText, Encoding.UTF8);

                bottomPageNavigatorHolder.Controls.Add(pageNavigator);
            }
            else
            {
                var emptyScreenControl = new EmptyScreenControl
                    {
                        ImgSrc = WebImageSupplier.GetAbsoluteWebPath("forums_icon.png", ForumManager.Settings.ModuleID),
                        Header = Resources.ForumResource.EmptyScreenSearchCaption,
                        Describe = Resources.ForumResource.EmptyScreenSearchText,
                    };

                topicListHolder.Controls.Add(emptyScreenControl);
            }

            (Master as ForumMasterPage).CurrentPageCaption = HeaderStringHelper.GetHTMLSearchHeader(_isFindByTag ? tagName : searchText);

            Title = HeaderStringHelper.GetPageTitle((Master as ForumMasterPage).CurrentPageCaption);
        }
예제 #6
0
        private void SetTotalPostsCount(int count)
        {
            var pageNavigator = new PageNavigator
                {
                    PageUrl = string.Format(
                        CultureInfo.CurrentCulture,
                        "{0}?{1}",
                        VirtualPathUtility.ToAbsolute("~/products/community/modules/blogs/"),
                        QueryString("page")
                        //BlogsPageSize
                        ),
                    //"./" + "?" + QueryString("page"),
                    CurrentPageNumber = SelectedPage,
                    EntryCountOnPage = BlogsPageSize,
                    VisiblePageCount = 5,
                    ParamName = "page",
                    EntryCount = count
                };

            blogsCount = count;
            pageNavigatorHolder.Controls.Add(pageNavigator);
        }