Example #1
0
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        // ***********************************************************************/
        protected override void InitializeSkin(Control skin)
        {
            IDataProviderBase dp = DataProvider.Instance();
            int LC;
            LC = dp.GetLastCount((UlterSystems.PortalLib.BusinessObjects.Person.RequestUser().ID).ToString());

            // Find the thread tracking thread list control
            threadTracking = (ThreadList)skin.FindControl("ThreadTracking");
            if (null != threadTracking)
            {
                ThreadCollection trackedThreads = Threads.GetThreadsUserIsTracking(ForumUser.Username);

                if (trackedThreads.Count > 0)
                {
                    threadTracking.DataSource = trackedThreads;
                    threadTracking.DataBind();
                }
                else
                {
                    threadTracking.Visible = false;
                    Label label = (Label)skin.FindControl("NoTrackedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }

                }
            }

            // Find the participated threads control
            participatedThreads = (ThreadList)skin.FindControl("ParticipatedThreads");
            LastCount = (DropDownList)skin.FindControl("LastCount");
            LastCount.SelectedIndex = (LC - 5) / 5;
            LastCount.SelectedIndexChanged += new System.EventHandler(LastCount_SelectedIndexChanged);
            LastCount_SelectedIndexChanged(null, null);

            if (null != participatedThreads)
            {
                ThreadCollection participatedInThreads = Threads.GetThreadsUserMostRecentlyParticipatedIn(ForumUser.Username, LC);

                if (participatedInThreads.Count > 0)
                {
                    participatedThreads.DataSource = participatedInThreads;
                    participatedThreads.DataBind();
                }
                else
                {
                    participatedThreads.Visible = false;
                    Label label = (Label)skin.FindControl("NoParticipatedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }
                }
            }
        }
Example #2
0
        // *********************************************************************
        //  Initializeskin
        //
        /// <summary>
        /// Initialize the control template and populate the control with values
        /// </summary>
        // ***********************************************************************/
        override protected void InitializeSkin(Control skin)
        {
            // Find the thread tracking thread list control
            threadTracking = (ThreadList)skin.FindControl("ThreadTracking");
            if (null != threadTracking)
            {
                ThreadCollection trackedThreads = Threads.GetThreadsUserIsTracking(ForumUser.Username);

                if (trackedThreads.Count > 0)
                {
                    threadTracking.DataSource = trackedThreads;
                    threadTracking.DataBind();
                }
                else
                {
                    threadTracking.Visible = false;
                    Label label = (Label)skin.FindControl("NoTrackedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }
                }
            }

            // Find the participated threads control
            participatedThreads = (ThreadList)skin.FindControl("ParticipatedThreads");
            if (null != participatedThreads)
            {
                ThreadCollection participatedInThreads = Threads.GetThreadsUserMostRecentlyParticipatedIn(ForumUser.Username);

                if (participatedInThreads.Count > 0)
                {
                    participatedThreads.DataSource = participatedInThreads;
                    participatedThreads.DataBind();
                }
                else
                {
                    participatedThreads.Visible = false;
                    Label label = (Label)skin.FindControl("NoParticipatedThreads");
                    if (null != label)
                    {
                        label.Visible = true;
                    }
                }
            }


            // Find the search link
            search = (HyperLink)skin.FindControl("FindMorePosts");
            if (null != search)
            {
                search.NavigateUrl = Globals.UrlSearchForPostsByUser + ForumUser.Username;
            }
        }
        // *********************************************************************
        //  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;

            // 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("All Days", "0"));
                daysToDisplay.Items.Add(new ListItem("Today", "1"));
                daysToDisplay.Items.Add(new ListItem("Past 3 Days", "3"));
                daysToDisplay.Items.Add(new ListItem("Past Week", "7"));
                daysToDisplay.Items.Add(new ListItem("Past 2 Weeks", "14"));
                daysToDisplay.Items.Add(new ListItem("Past Month", "30"));
                daysToDisplay.Items.Add(new ListItem("Past 3 Months", "90"));
                daysToDisplay.Items.Add(new ListItem("Past 6 Months", "180"));
                daysToDisplay.Items.Add(new ListItem("Past Year", "360"));
                daysToDisplay.AutoPostBack = true;
            }

            // Display posts that the user has already read
            hideReadThreads = (CheckBox)skin.FindControl("HideReadThreads");
            if (hideReadThreads != null)
            {
                if (ForumUser != null)
                {
                    hideReadThreads.Checked         = ForumUser.HideReadThreads;
                    hideReadThreads.AutoPostBack    = true;
                    hideReadThreads.Visible         = true;
                    hideReadThreads.CheckedChanged += new System.EventHandler(HideReadThreads_Changed);
                }
                else
                {
                    hideReadThreads.Visible = false;
                }
            }

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

            // Set the anchor
            link = (HyperLink)skin.FindControl("NewThreadLinkTop");
            if (link != null)
            {
                link.NavigateUrl = Globals.UrlAddNewPost + ForumID;
            }

            link = (HyperLink)skin.FindControl("NewThreadLinkBottom");
            if (link != null)
            {
                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(), username, ForumUser.HideReadThreads);
                }
                else
                {
                    pager.TotalRecords = Forums.GetTotalThreadsInForum(ForumID, threadMaxValue, CalculateDateTimeFilter(), username, hideReadThreads.Checked);
                }
            }
            else
            {
                pager.TotalRecords = Forums.GetTotalThreadsInForum(ForumID, threadMaxValue, CalculateDateTimeFilter(), null, false);
            }
        }
Example #4
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());
            }
        }