⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forumgroupview.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.Controls;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls 
{

    // *********************************************************************
    //  ForumView
    //
    /// <summary>
    /// This server control is used to display top level threads. Note, a thread
    /// is a post with more information. The Thread class inherits from the Post
    /// class.
    /// </summary>
    /// 
    // ********************************************************************/
    public class ForumGroupView : SkinnedWebControl 
    {
        CSContext csContext = CSContext.Current;
        string skinFilename = "View-ForumGroupView.ascx";
        protected Repeater repeater;

        // *********************************************************************
        //  ForumGroupView
        //
        /// <summary>
        /// The constructor simply checks for a ForumID value passed in via the
        /// HTTP POST or GET.
        /// properties.
        /// </summary>
        /// 
        // ********************************************************************/
        public ForumGroupView() 
        {

            // Assign a default template name
            if (SkinFilename == null)
                SkinFilename = skinFilename;

        }

        public override void DataBind() 
        {
            this.EnsureChildControls();

            ArrayList forumGroups = null;

            // Don't data bind if the data source is already populated
            //
            if (repeater.DataSource != null)
                return;

            // Get all forum groups if we're auto-databinding
            // we always cache
            //
            switch (Mode) 
            {

                case ControlUserMode.Administrator:
                    forumGroups = ForumGroups.GetForumGroups(false);

                    // Ignore collapse/expand information
                    foreach (Group group in forumGroups)
                        group.HideSections = false;

                    break;

                case ControlUserMode.Moderator:
                    forumGroups = ForumGroups.GetForumGroups(false,false,true, true);

                    // Ignore collapse/expand information
                    foreach (Group group in forumGroups)
                        group.HideSections = false;

                    break;

                default:
                    forumGroups = ForumGroups.GetForumGroups(true);
                    break;


            }

            // Have we asked for a particular forum group?
            //
            if (csContext.ForumGroupID > 0) 
            {

                ArrayList newForumGroups = new ArrayList();

                // Try to find the requested forum group
                foreach (Group f in forumGroups) 
                {

                    if (f.GroupID == csContext.ForumGroupID) 
                    {
                        f.HideSections = false;
                        newForumGroups.Add(f);
                    }

                }

                forumGroups = newForumGroups;

            }

            // Databind if we have values
            //
            if (forumGroups.Count > 0) 
            {
                repeater.DataSource = forumGroups;
                repeater.DataBind();
            }

        }

        // *********************************************************************
        //  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) 
        {

            repeater = (Repeater) skin.FindControl("forumGroupRepeater");

            // Add an item command to the forum group repeater
            //
            repeater.ItemCreated += new RepeaterItemEventHandler(repeater_ItemCreated);

//            Control row_Login = skin.FindControl("row_Login");
//            if(row_Login != null)
//                row_Login.Visible = !CSContext.Current.User.IsAnonymous;



            // Databind the forum group repeater
            //
            DataBind();

        }

        private void repeater_ItemCreated(Object sender, RepeaterItemEventArgs e) 
        {
			if( e.Item.ItemType == ListItemType.Item ||
				e.Item.ItemType == ListItemType.AlternatingItem ) {
				ImageButton b = (ImageButton) e.Item.FindControl("ExpandCollapse");

				if (b != null) {
//					if (csContext.ForumGroupID > 0) {
//						b.Visible = false;
//					} 
//					else {
//						b.Command += new CommandEventHandler(ExpandCollapse_Command);
//					}

					if( CSContext.Current.User.EnableCollapsingPanels && CSContext.Current.SiteSettings.EnableCollapsingPanels &&
						(csContext.ForumGroupID <= 0) ) {

						b.Visible = true;
						b.Command += new CommandEventHandler(ExpandCollapse_Command);
					}
					else 
						b.Visible = false;

				}
			}
        }

        public void ExpandCollapse_Command( object sender, CommandEventArgs e ) 
        {

            ArrayList groups = (ArrayList) repeater.DataSource;
            int fgID = Convert.ToInt32( e.CommandArgument );
            UserCookie userCookie = csContext.User.GetUserCookie();

            // Run through each group and set the appropriate display
            //
            foreach (Group g in groups) 
            {

                if (g.GroupID == fgID) 
                {
						if ( g.HideSections ) {
							g.HideSections = false;
							userCookie.RemoveHiddenForumGroup(g.GroupID);
						} 
						else {
							userCookie.AddHiddenForumGroup(g.GroupID);
							g.HideSections = true;
						}
                }

            }

            if ( HttpContext.Current != null ) 
            {
                HttpContext context = HttpContext.Current;
                context.Response.Redirect( context.Request.RawUrl );
            } 
            else 
            {
                repeater.DataSource = groups;
                repeater.DataBind();
            }

        }




    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -