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

📄 forumpost.cs

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

using System;
using System.Collections;
using System.Drawing;
using System.Text.RegularExpressions;
using CommunityServer.Components;

namespace CommunityServer.Discussions.Components
{
	/// <summary>
	/// Summary description for ForumPost.
	/// </summary>
	public class ForumPost : Post
	{
		public ForumPost()
		{
			
		}

        #region Section Implementation
        Section section;

        public override Section Section
        {
            get 
            {
                if (section == null) 
                {
                    if (this.SectionID >= 0)
                        section = Forums.GetForum(this.SectionID);
                }

                return section;
            }
            set 
            {
                section = value;
            }
        }
        #endregion

		public Forum Forum {
			get {
				return (Forum) this.Section;
			}
			set {
				this.Section = value;
			}
		}

        #region GetBodySummary
        // *********************************************************************
        //
        //  BodySummary
        //
        /// <summary>
        /// Returns a summarized version of the post body
        /// </summary>
        //
        // ********************************************************************/
        public string GetBodySummary (int size, string terms, Color color, Color bgColor) 
        {
            string[] highlightWords = terms.Split(' ');

            return GetBodySummary (size, highlightWords, color, bgColor);
        }

        public string GetBodySummary(int size, string[] highlightWords, Color color, Color bgColor) 
        {
			// EAD 6/27/04: New function I wrote a month ago to strip all
			// tags out and replace with line breaks.  In this case, we need to
			// insert <br />s inplace of line breaks so it looks somewhat neat.
			//
			// LN 6/23/04 : Do not Html encode the body
			// postBody = Globals.HtmlEncode(Transforms.StripHtmlXmlTags(postBody));
			// postBody = Transforms.StripHtmlXmlTags(postBody);
			string postBody = Formatter.StripAllTags(FormattedBody);

            // We only want to display some of the body
            //
            if (size > 0 && postBody.Length > size) 
            {
                int whitespace = 0;
                // Clip the body
                postBody = postBody.Substring(0, size);

                // Find the last occurence of a space
                whitespace = postBody.LastIndexOf(" ");

                if( whitespace == -1 )
                    whitespace = size;
				
                // Rebuild postBody string
                postBody = postBody.Substring(0, whitespace) + " ...";
            }

			// Do any word highlighting
            //
            if (highlightWords.Length > 0 ) 
            {
                string delimitedString;

                // Split and delimit string
                //
                delimitedString = Transforms.ToDelimitedString(highlightWords, "|");

                // TDD 7/19/2004
                // this string is used as the regex pattern. if it contains special characters like (,* $ it
                // throw an error since these are special instruction characters to Regex. We must escape these
                // special characters if they are used as search strings.
                delimitedString = Regex.Escape( delimitedString );
                // Perform replacement
                //
                postBody = Regex.Replace(postBody, delimitedString, "<span style=\"color:" + color.Name + ";background-color:" + bgColor.Name + "\"><b>$0</b></span>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);
            }

            return postBody;
        }
        #endregion

        private ArrayList ratings = null;
        public ArrayList Ratings 
        {
            get 
            {
                if ((ratings == null) && (this.PostLevel == 1))
                    ratings = CommunityServer.Components.Ratings.GetRatings(this.ThreadID);

                return ratings;
            }
                
        }

	}
}

⌨️ 快捷键说明

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