Exemplo n.º 1
0
        public override void OnPreRender()
        {
            // Determine whether we are in flat view or tree view mode.  This setting is
            // stored in a cookie, but should probably be moved in to the user's profile
            // which is stored in the database.
            if (!_viewDropDownSelected)
            {
                _forumView = ForumUtils.GetForumView(Page);
            }
            ListItem listItem = _viewDropDownList.Items.FindByValue(_forumView.ToString());

            if (listItem != null)
            {
                listItem.Selected = true;
            }

            // _threadID identifies the thread we are currently viewing.  _postID identifies
            // the post within the thread that is currently being shown. (i.e. in tree view,
            // only one post can be viewed at a time).  _threadID can be obtained from the value
            // of _postID.  We will also determine what page we are looking at.
            _threadID   = ForumDB.GetThreadFromPost(_postID);
            _threadPage = ForumDB.GetSortOrderFromPost(_postID, _forumView) / ForumUtils.GetPostsPerPage();

            // If looking at the first post in a thread, then increment the thread view count
            if (_threadID == _postID)
            {
                ForumDB.IncrementThreadViews(_threadID);
            }

            // Get page of posts that will be rendered
            _forumPostCollection = ForumDB.GetThread(_threadID, _threadPage, ForumUtils.GetPostsPerPage(), _forumView);

            // Register javascript for dynamically showing threads in tree view
            if (_forumView == ForumUtils.ForumView.TreeViewDynamic)
            {
                RegisterJavascript();
            }
        }
Exemplo n.º 2
0
        private void RenderThreads(HtmlTextWriter writer)
        {
            // Render header row
            writer.AddAttribute(HtmlTextWriterAttribute.Height, "25");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "left");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionHeader");
            writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(" Thread ");
            writer.RenderEndTag();              // Td

            // Started by column
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionHeader");
            writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(" Started By ");
            writer.RenderEndTag();              // Td

            // Replies column
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionHeader");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(" Replies ");
            writer.RenderEndTag();              // Td

            // Views column
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionHeader");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(" Views ");
            writer.RenderEndTag();              // Td

            // Last Post column
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionHeader");
            writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write(" Last Post ");
            writer.RenderEndTag();              // Td
            writer.RenderEndTag();              // Tr

            // Work out when to display new images
            string   cookieName  = "Forum" + ForumID + "_LastVisited";
            DateTime lastVisited = Convert.ToDateTime(Page.Session[cookieName]);

            // Loop round thread items, rendering information about individual threads
            string document = GetDocument();
            string images   = GetImages();

            foreach (ForumThreadInfo forumThreadInfo in _forumThreadInfoCollection)
            {
                forumThreadInfo.Render(writer, ForumUtils.GetPostsPerPage(), lastVisited, Page, images, document, ForumUtils.GetPostsPerPage(), ForumUtils.GetForumView(Page));
            }
        }