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

📄 inlinetageditor.cs

📁 community server 源码
💻 CS
字号:
using System;
using CommunityServer.Components;
using System.Collections;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls
{
	/// <summary>
	/// Summary description for InlineTagEditor.
	/// </summary>
	public class InlineTagEditor : CommunityServer.Controls.InlineTagEditor
	{
		CSContext csContext = CSContext.Current;

		public override void SaveTags(int postID, string[] tags)
		{
			if (this.IsEditable(postID))
			{
				ForumPost post = Posts.GetPost(postID, csContext.User.UserID);
				post.Categories = tags;
				Posts.UpdatePost(post, csContext.User.UserID);
			}
		}

		public override string GetUrl(string tag)
		{
			return SiteUrls.Instance().TagsBrowser(new string[] { tag });
		}

		public override bool IsEditable (int postID)
		{
			return IsEditable();
		}

		public override bool IsEditable()
		{
			return Permissions.ValidatePermissions(this.Forum, Permission.Moderate | Permission.Edit, csContext.User);
		}

		Forum _forum = null;
		public Forum Forum
		{
			get
			{
				if (_forum == null)
				{
					if (csContext.SectionID > 0)
						_forum = Forums.GetForum(csContext.SectionID);
					else if (csContext.PostID > 0)
						_forum = Forums.GetForumByPostID(csContext.PostID, csContext.User.UserID, true);
				}

				return _forum;
			}
			set
			{
				_forum = value;
				_availableTags = null;
			}
		}

		string[] _availableTags = null;
		public override string[] AvailableTags 
		{ 
			get
			{
				if (_availableTags == null)
				{
					ArrayList allTags = PostCategories.GetCategories(this.Forum.SectionID, true, false);
					ArrayList availableTags = new ArrayList();
					foreach (PostCategory pc in allTags)
					{
						availableTags.Add(pc.Name);
					}

					_availableTags = (string[]) availableTags.ToArray(typeof(string));
				}

				return _availableTags;
			}
		}
	}
}

⌨️ 快捷键说明

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