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

📄 tagposts.aspx.cs

📁 community server 源码
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

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


namespace CommunityServerWeb.ControlPanel.Moderation
{
	/// <summary>
	/// Summary description for TagPosts.
	/// </summary>
	public class TagPosts : BaseModerationPage
	{
		CSContext context = CSContext.Current;
		protected Repeater thePosts;
		protected IPagedControl pager;

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		/// <summary>
		/// The users prefered Grid Page Size, Will return default values before the OnLoad event
		/// Due to dependancy on CSConect.Current.User
		/// </summary>
		public int DefaultPageSize
		{
			get
			{
				return Globals.SafeInt(this.CurrentUser.GetExtendedAttribute("CPPageSize"),10);
			}
		}

		private void Page_Load(object sender, EventArgs e)
		{
			thePosts.ItemCreated +=new RepeaterItemEventHandler(thePosts_ItemCreated);
			JavaScript.RegisterRefresh(this);
			
			if(!IsPostBack)
			{
				string action = Request.QueryString["action"];
				if(action != null)
					HandleActions(action);

				pager.PageSize = Globals.SafeInt(this.CurrentUser.GetExtendedAttribute("CPPageSize"),10);
				SearchResultSet results = CommunityServer.Components.Tags.GetPostsMatchingTags(ApplicationType.Forum, context.Tags, pager.PageIndex, pager.PageSize, true, false);
				pager.TotalRecords = results.TotalRecords;

				thePosts.DataSource = results.Posts;
				thePosts.DataBind();
			}
		}

		private void HandleActions(string action)
		{
			if(action != null && Request.QueryString["postids"] != null)
			{
				action = action.ToLower();
				ArrayList postList = new ArrayList();
				foreach (string sId in Request.QueryString["postids"].Split(','))
				{
					postList.Add(int.Parse(sId));
				}

				int[] postIds = (int[]) postList.ToArray(typeof(int));
				
				switch (action)
				{
					case "remove":
						foreach (int postId in postIds)
						{
							ForumPost post = Posts.GetPost(postId, context.User.UserID, false, false, true);
							if (post.Categories != null && post.Categories.Length > 0)
							{
								ArrayList categories = new ArrayList();
								bool requiresSave = false;
								foreach (string category in post.Categories)
								{
									if (string.Compare(category, context.Tags[0], false) != 0)
										categories.Add(category);
									else
										requiresSave = true;
								}

								if (requiresSave)
								{
									post.Categories = (string[]) categories.ToArray(typeof(string));
									Posts.UpdatePost(post, context.User.UserID);
								}
							}
						}

						break;
				}
			}
		}

		public string GetFilteredUrl()
		{
			string url  = "{0}?Tags={1}";
			url = string.Format(url,Request.Path,Globals.UrlEncodePathComponent(context.Tags[0]));
			return url;
		}

		protected string GetActionUrl(string action, object PostID)
		{
			return GetFilteredUrl() + "&action="+ action + "&postids=" + PostID.ToString();
		}

		private void thePosts_ItemCreated(object sender, RepeaterItemEventArgs e)
		{
			if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
			{
               
			}
		}
	}
}

⌨️ 快捷键说明

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