Пример #1
0
        // *********************************************************************
        //  InitializeControlTemplate
        //
        /// <summary>
        /// Initializes the user control loaded in CreateChildControls. Initialization
        /// consists of finding well known control names and wiring up any necessary events.
        /// </summary>
        /// 
        // ********************************************************************/
        protected override void InitializeSkin(Control skin)
        {
            // Find the UserList server control in our template
            userList = (UserList)skin.FindControl("UserList");
            userList.EnableViewState = false;

            // Find the pager control
            pager = (Paging)skin.FindControl("Pager");
            // Get the total records used in the pager
            pager.PageSize = 50;
            pager.TotalRecords = Users.TotalNumberOfUserAccounts();
            pager.PageIndex_Changed += new System.EventHandler(PageIndex_Changed);

            if (!Page.IsPostBack)
                SetDataSource();
        }
Пример #2
0
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initializes the user control loaded in CreateChildControls. Initialization
        /// consists of finding well known control names and wiring up any necessary events.
        /// </summary>
        /// 
        // ********************************************************************/
        protected override void InitializeSkin(Control skin)
        {
            // Images
            HyperLink link;
            OrderBy = (DropDownList)skin.FindControl("OrderBy");
            OrderType = (DropDownList)skin.FindControl("OrderTyp");

            if (null != ForumUser)
                username = ForumUser.Username;

            // Ensure we have a valid forum
            try
            {
                forum = Forums.GetForumInfo(ForumID);
            }
            catch (Components.ForumNotFoundException)
            {
                Page.Response.Redirect(Globals.UrlMessage + Convert.ToInt32(Messages.UnknownForum));
                Page.Response.End();
            }

            // Find the label that we use when there are no threads available
            noThreads = (Label)skin.FindControl("NoThreads");
            noPostsDueToFilter = (Label)skin.FindControl("NoPostsDueToFilter");

            // Find the forum name
            forumName = (HyperLink)skin.FindControl("ForumName");
            if (forumName != null)
            {
                forumName.Text = forum.Name;
                forumName.NavigateUrl = Globals.UrlShowForum + ForumID;
            }

            // Find the forum Description
            forumDescription = (Label)skin.FindControl("ForumDescription");
            if (forumDescription != null)
                forumDescription.Text = forum.Description;

            // Find the thread list
            threadList = (ThreadList)skin.FindControl("ThreadList");

            // Find the link button to mark all as read
            markAllRead = (LinkButton)skin.FindControl("MarkAllRead");
            if (markAllRead != null)
            {
                if (username != null)
                {
                    markAllRead.Visible = true;
                    markAllRead.Click += new System.EventHandler(MarkAllRead_Click);
                }
                else
                {
                    markAllRead.Visible = false;
                }
            }

            // Find the search text box
            search = (TextBox)skin.FindControl("Search");

            // Find the search button
            searchButton = (Button)skin.FindControl("SearchButton");
            if (searchButton != null)
            {
                searchButton.Click += new System.EventHandler(Search_Click);
            }

            // This allows the user to control the total number of threads displayed
            daysToDisplay = (DropDownList)skin.FindControl("DisplayByDays");
            if (daysToDisplay != null)
            {
                daysToDisplay.SelectedIndexChanged += new System.EventHandler(SelectedDays_Changed);
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "All").ToString(), "0"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "Today").ToString(), "1"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "3 Days").ToString(), "3"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "Week").ToString(), "7"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "2 Weeks").ToString(), "14"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "Month").ToString(), "30"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "3 Moths").ToString(), "90"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "6 Months").ToString(), "180"));
                daysToDisplay.Items.Add(new ListItem(HttpContext.GetLocalResourceObject(Globals.SkinsDir + "ThreadView", "Year").ToString(), "360"));
                daysToDisplay.AutoPostBack = true;
            }
            DropDownList ddlOrderBy = (DropDownList)skin.FindControl("OrderBy");
            if (ddlOrderBy != null)
            {
                foreach (ListItem i in ddlOrderBy.Items)
                    i.Text = HttpContext.GetLocalResourceObject(Globals.SkinsDir + "skin-showforum.ascx", "SortBy" + i.Value).ToString();

            }

            // Find the new thread button(s)
            newThreadTop = (System.Web.UI.WebControls.Image)skin.FindControl("NewThreadImageTop");
            if (newThreadTop != null)
                newThreadTop.ImageUrl = Globals.ApplicationVRoot + Globals.ForumsDirectory + "/Skins/" + SkinName + "/images"+ Globals.LangDir +"post.gif";

            // Set the anchor
            link = (HyperLink)skin.FindControl("NewThreadLinkTop");
            if (link != null)
                if (HttpContext.Current.User.Identity.IsAuthenticated && Users.GetLoggedOnUser().IsApproved)
                    link.NavigateUrl = Globals.UrlAddNewPost + ForumID;

            link = (HyperLink)skin.FindControl("NewThreadLinkBottom");
            if (link != null)
                if (HttpContext.Current.User.Identity.IsAuthenticated && Users.GetLoggedOnUser().IsApproved)
                    link.NavigateUrl = Globals.UrlAddNewPost + ForumID;

            // Find the pager
            pager = (Paging)skin.FindControl("Pager");
            // Get the total records used in the pager
            if (ForumUser != null)
            {
                if (!Page.IsPostBack)
                    pager.TotalRecords = Forums.GetTotalThreadsInForum(ForumID, threadMaxValue, CalculateDateTimeFilter());
                else
                    pager.TotalRecords = Forums.GetTotalThreadsInForum(ForumID, threadMaxValue, CalculateDateTimeFilter());
            }
            else
            {
                pager.TotalRecords = Forums.GetTotalThreadsInForum(ForumID, threadMaxValue, CalculateDateTimeFilter());
            }
        }
Пример #3
0
        // *********************************************************************
        //  InitializePostListControlTemplate
        //
        /// <summary>
        /// Render the post list view
        /// </summary>
        /// 
        // ********************************************************************/
        private void InitializePostListControlTemplate()
        {
            // Initialize common display elements
            InitializeCommonTemplateItems();

            // Find the postList control
            postList = (PostList)controlTemplate.FindControl("PostList");

            // Find the pager
            pager = (Paging)controlTemplate.FindControl("Pager");
            pager.PageIndex_Changed += new System.EventHandler(PageIndex_Changed);

            // Get the total records used in the pager
            pager.TotalRecords = Threads.GetTotalPostsForThread(PostID);
            pager.TotalPages = Paging.CalculateTotalPages(pager.TotalRecords, pager.PageSize, Threads.GetTotalPinnedPostsForThread(PostID));

            // Set up the email tracking check changed event
            postList.ThreadTracking_Changed += new System.EventHandler(Toggle_ThreadTracking);

            postList.DataSource = Posts.GetThreadByPostID(PostID, pager.PageIndex, pager.PageSize);
            postList.DataBind();
        }