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

📄 forumformatter.cs

📁 解压即可使用
💻 CS
📖 第 1 页 / 共 3 页
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Text;
using System.Collections;
using System.Collections.Specialized;
using CommunityServer.Components;
using Group = System.Text.RegularExpressions.Group;

namespace CommunityServer.Discussions.Components
{
	/// <summary>
	/// Summary description for ForumFormatter.
	/// </summary>
	public class ForumFormatter
	{
        #region static predefined values
        static string forumStatusIcon = "<img title=\"{0}\" alt=\"{0}\" src=\"{1}\"/>";
        static string threadStatusIcon = "<a href=\"{0}\"><img title=\"{1}\" src=\"{2}\" border=\"0\" /></a>";
        #endregion

		private ForumFormatter()
		{
			//
			// TODO: Add constructor logic here
			//
		}

        #region ForumFormatter
        
        #region Format Private Message Recipients
        public static string FormatPrivateMessageRecipients (PrivateMessage message) 
        {
            if (message.Recipients == null)
                // LN 5/31/04 : returns "Not available"
                return ResourceManager.GetString("NotAvailable"); //string.Empty;

            CSContext csContext = CSContext.Current;
            StringBuilder s = new StringBuilder();

            for (int i = 0; i < message.Recipients.Count; i++) 
            {
                User user = (User) message.Recipients[i];

                // LN 5/31/04 : Workaround to keep stored procedures as they are now.
                // Check out if recipient's ID is AuthorID.
                // If yes, then the real recipient is current user.
                if (user.UserID != message.AuthorID)
                    s.Append( Formatter.FormatUsername( user.UserID, user.Username ) );
                else
                    s.Append( Formatter.FormatUsername( csContext.User.UserID, csContext.User.Username ) );

                if ((i+1) < message.Recipients.Count)
                    s.Append(", ");

            }

            // LN 5/31/04 : returns "Not available"
            if (s.Length > 0)
                return s.ToString();
            else
                return ResourceManager.GetString("NotAvailable");

        }
        #endregion

        
        #region Format Forum Name in ThreadView
        public static string ForumNameInThreadView (Thread thread) 
        {
            CSContext csContext = CSContext.Current;

            if (thread.SectionID != csContext.ForumID)
                return "<span class=\"inlineLink\" onclick=\"window.open('" + ForumUrls.Instance().Forum(thread.SectionID) + "')\"> in " + thread.Section.Name + "</span>";
            
            return string.Empty;

        }
        #endregion

        
        #region Format User Location
        public static string FormatLocation ( string encodedString ) 
        {
            return FormatLocation ( encodedString, true );
        }


        public static string FormatLocation ( string encodedString, bool createLink) 
        {
            ForumPost p;
            Forum f;
            CommunityServer.Components.Group fg;
            SiteUrls.ForumLocation location = SiteUrls.GetForumLocation(encodedString);
            string url = "";

            if ( createLink )
                url = "<a href=\"{0}\">{1}</a>";
            else
                url = "{1}";

            switch (location.UrlName) 
            {
                case "/":
                    location.Description = string.Format(url, Globals.GetSiteUrls().Home, ResourceManager.GetString("Location_Home"));
                    break;

                case "/default.aspx":
                    location.Description = string.Format(url, Globals.GetSiteUrls().Home, ResourceManager.GetString("Location_Home"));
                    break;

                case "faq":
                    location.Description = string.Format(url, Globals.GetSiteUrls().FAQ, ResourceManager.GetString("Location_Faq"));
                    break;

                case "user_List":
                    location.Description = string.Format(url, Globals.GetSiteUrls().UserList, ResourceManager.GetString("Location_MemberList"));
                    break;

                case "user":
                    string username = Users.GetUser(location.UserID, false).Username;
                    location.Description = string.Format(ResourceManager.GetString("Location_MemberProfile"), string.Format(url, Globals.GetSiteUrls().UserProfile(location.UserID), username));
                    break;

                case "forum":
                    try 
                    {
                        f = Forums.GetForum(location.ForumID);
                        location.Description = string.Format(ResourceManager.GetString("Location_Forum"), string.Format(url, ForumUrls.Instance().Forum(location.ForumID), f.Name));
                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "searchFriendlyForum":
                    try 
                    {
                        f = Forums.GetForum(location.ForumID);
                        location.Description = string.Format(ResourceManager.GetString("Location_Forum"), string.Format(url, ForumUrls.Instance().Forum(location.ForumID), f.Name));
                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "post":
                    try 
                    {
                        p = Posts.GetPost(location.PostID, CSContext.Current.User.UserID);

                        location.Description = string.Format(ResourceManager.GetString("Location_PostView"), string.Format(url, Globals.GetSiteUrls().Post(location.PostID), p.Subject));

                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "searchFriendlyPost":
                    try 
                    {
                        p = Posts.GetPost(location.PostID, CSContext.Current.User.UserID);

                        location.Description = string.Format(ResourceManager.GetString("Location_PostView"), string.Format(url, Globals.GetSiteUrls().Post(location.PostID), p.Subject));

                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "forumGroup":
                    try 
                    {
                        fg = ForumGroups.GetForumGroup(location.ForumGroupID);
                        location.Description = string.Format(ResourceManager.GetString("Location_ForumGroup"), string.Format(url, Globals.GetSiteUrls().ForumGroup(location.ForumGroupID), fg.Name));
                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "searchFriendlyForumGroup":
                    try 
                    {
                        fg = ForumGroups.GetForumGroup(location.ForumGroupID);
                        location.Description = string.Format(ResourceManager.GetString("Location_ForumGroup"), string.Format(url, Globals.GetSiteUrls().ForumGroup(location.ForumGroupID), fg.Name));
                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "post_Reply":
                    try 
                    {
                        p = Posts.GetPost(location.PostID, CSContext.Current.User.UserID);

                        location.Description = string.Format(ResourceManager.GetString("Location_PostReply"), string.Format(url, Globals.GetSiteUrls().Post(location.PostID), p.Subject));
                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "post_Create":
                    try 
                    {
                        f = Forums.GetForum(location.ForumID);
                        location.Description = string.Format(ResourceManager.GetString("Location_PostNew"), string.Format(url, ForumUrls.Instance().Forum(location.ForumID), f.Name));
                    } 
                    catch 
                    {
                        location.Description = ResourceManager.GetString("Location_Hidden");
                    }
                    break;

                case "whoIsOnline":
                    location.Description = string.Format(url, Globals.GetSiteUrls().WhoIsOnline, ResourceManager.GetString("Location_WhoIsOnline"));
                    break;

                case "post_Active":
                    location.Description = string.Format(url, Globals.GetSiteUrls().PostsActive, ResourceManager.GetString("Location_ActiveTopics"));
                    break;

                case "post_Unanswered":
                    location.Description = string.Format(url, Globals.GetSiteUrls().PostsUnanswered, ResourceManager.GetString("Location_UnansweredTopics"));
                    break;

                case "user_ForgotPassword":
                    location.Description = string.Format(url, Globals.GetSiteUrls().UserForgotPassword, ResourceManager.GetString("Location_Login"));
                    break;

                case "user_Register":
                    location.Description = ResourceManager.GetString("Location_Hidden");
                    break;

                case "user_EditProfile":
                    location.Description = ResourceManager.GetString("Location_Hidden");
                    break;

                case "logout":
                    location.Description = string.Format(url, Globals.GetSiteUrls().Logout, ResourceManager.GetString("Location_Logout"));
                    break;

                case "login":
                    location.Description = string.Format(url, Globals.GetSiteUrls().Login, ResourceManager.GetString("Location_Login"));
                    break;

                case "search":
                case "search_ForText":
                case "search_ByUser":
                    location.Description = ResourceManager.GetString("Location_Hidden");
                    break;

                case "user_MyForums":
                    location.Description = ResourceManager.GetString("Location_Hidden");
                    break;

                case "user_ChangePassword":
                    location.Description = ResourceManager.GetString("Location_Hidden");
                    break;

                case "user_ChangePasswordAnswer":
                    location.Description = ResourceManager.GetString("Location_Hidden");
                    break;

                default:
                    location.Description = ResourceManager.GetString("Location_NotFound");
                    break;
            }

            /*
                        // User is viewing search
                        if ((location.UrlName == search) || (location.UrlName.IndexOf(search_ForText) > 0) || (location.UrlName.IndexOf(search_ByUser) > 0))
                            location.Description =  String.Format(anchor, location.UrlName, ResourceManager.GetString("Locations_Search"));

                        if (location.UrlName == user_MyForums)
                            location.Description =  ResourceManager.GetString("Locations_MyForum");

                        if (location.UrlName == user_ChangePassword)
                            location.Description =  ResourceManager.GetString("Locations_EditUserProfile");

                        // Viewing a forum
                        if (location.UrlName.IndexOf(forum) > 0) {
                            Forum f = Forums.GetForum( int.Parse( queryParams["ForumID"] ) );

                            location.Description =  String.Format(anchor, location.UrlName, string.Format(ResourceManager.GetString("Locations_ViewingTopic"), f.Name));
                        }

                        // Add a new post
                        if (location.UrlName.IndexOf(post_Create) > 0) {
                            Forum f = Forums.GetForum( int.Parse( queryParams["ForumID"] ) );

                            location.Description =  String.Format(anchor, Resolvelocation.UrlName(forum) + f.ForumID, string.Format(ResourceManager.GetString("Locations_Posting"), f.Name));
                        }

                        // Viewing a post
                        if (location.UrlName.IndexOf(post) > 0) {
                            Post p = Posts.GetPost( int.Parse( queryParams["PostID"] ), 0);

                            if (p == null)
                                location.Description =  ResourceManager.GetString("ReadingPrivateTopic");
                            else
                                location.Description =  String.Format(anchor, location.UrlName, string.Format(ResourceManager.GetString("Locations_ReadingTopic"), p.Subject));
                        }
            */
            return location.Description;
        }
        #endregion

		#region Format Read Link
		public static string ReadLink (bool hasRead) {

			if (hasRead)
				return "lnk4";
			
			return "lnk3";
		}

⌨️ 快捷键说明

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