十分感谢lonestone
http://blog.csdn.net/lonestone/
CommnunityServer2.0由于其鲜明的web2.0特性和友好的用户界面以及强大的功能,吸引了包括我在内的越来越多的爱好者,不过相信对于官方原始版本的贴图和附件功能,一向是个问题,我想,最简单的解决方法就是给他的编辑器换成FCKeditor2.31,利用其可订制的上传文件功能来解决这个问题。
本例说涉及到的文件可以到这里下载。
说做就做,让我们打开vs2005,建立一个类库项目,比方说Cnfdc.FCKforCS,然后添加引用:
Communityserver.Controls
FredCK.FCKeditorV2
然后建立一个类,名叫FCK.cs
编写如下代码,对fCK按照cs要求的属性来进行封装:
namespace Cnfdc.FckForCs
{
    using CommunityServer.Controls;
    using FredCK.FCKeditorV2;
    using System;
    using System.Configuration;
    using System.Web.UI.WebControls;
    [Editor("FCK编辑器标准版", "FCK editor")]
    public class FCK : FCKeditor, ITextEditor
    {
        private int _columns;
        private bool _enableHTML = true;
        private int _rows;
        private string _styleName="Default";
        public FCK()
        {
            Modal m = new Modal();
            m.ModalType = ModalType.Window;
            this.Controls.Add(m);            
            this.ReConfigure();
        }
        protected override void OnPreRender(EventArgs e)
        {
            Configure();
            base.OnPreRender(e);
        }
        public void Configure()
        {
            if (this._enableHTML)
            {
                base.ToolbarSet = "Default";
            }
            else
            {
                base.ToolbarSet = "Basic";
            }
       }
        public void ReConfigure()
        {
            base.Height = Unit.Pixel(350);
            if (base.Width.IsEmpty)
            {
                base.Width = Unit.Pixel(685);
            }
            base.BasePath = ConfigurationSettings.AppSettings["FckEditor:BasePath"];
        }
        public virtual int Columns
        {
            get
            {
                return this._columns;
            }
            set
            {
                this._columns = value;
            }
        }
        Unit ITextEditor.Height
        {
            get
            {
                return base.Height;
            }
            set
            {
                base.Height = value;
            }
        }
        string ITextEditor.Text
        {
            get
            {
                return base.Value;
            }
            set
            {
                base.Value = value;
            }
        }
        Unit ITextEditor.Width
        {
            get
            {
                return base.Width;
            }
            set
            {
                base.Width = value;
            }
        }
        public virtual bool EnableHtmlModeEditing
        {
            get
            {
                return this._enableHTML;
            }
            set
            {
                this._enableHTML = value;
            }
        }
        public string GetClientSideMethod
        {
            get
            {
                return "";
            }
        }
        public virtual bool IsRichTextCapable
        {
            get
            {
                return base.CheckBrowserCompatibility();
            }
        }
        public virtual int Rows
        {
            get
            {
                return this._rows;
            }
            set
            {
                this._rows = value;
            }
        }
        public virtual string StyleName
        {
            get
            {
                if (this._styleName == null)
                {
                    this._styleName = "Default";
                }
                return this._styleName;
            }
            set
            {
                this._styleName = value;
                base.SkinPath = base.BasePath + "editor/skins/" + value + "/";
            }
        }

    }
}

然后将这个类库编译,拷贝生成的dll到cs的bin目录,同时将fckEditor的源码下载下来,注意要包括.net源码,将代码高亮的类放进去,以便使其中的代码高亮插件生效,然后也重新编译fckeditor,忘记说了,这个工作要放在FCK.cs前面,因为有dll版本依赖。
namespace FredCK.FCKeditorV2
{
    using System;
    using System.Collections;
    using System.IO;
    using System.Text.RegularExpressions;
    public class HighLighter
    {
        public HighLighter()
        {
            this.replaceEnter = false;
        }
        public string colorText(string tmpCode, string pathToDefFile, string language)
        {
            language = language.ToLower();
            if ((language == "c#") || (language == "csharp"))
            {
                language = "cs";
            }
            language = language.Replace(""", "");
            string text1 = "";
            string text2 = "";
            bool flag1 = true;
            ArrayList list1 = new ArrayList();
            ArrayList list2 = new ArrayList();
            try
            {
                StreamReader reader1 = new StreamReader(pathToDefFile + language.ToString() + ".def");
                string text3 = "";
                string text4 = "";
                while (reader1.Peek() != -1)
                {
                    text3 = reader1.ReadLine();
                    if (text3 != "")
                    {
                        if (text3.Substring(0, 1) == "-")
                        {
                            if (text3.ToLower().IndexOf("keywords") > 0)
                            {
                                text4 = "keywords";
                            }
                            if (text3.ToLower().IndexOf("keytypes") > 0)
                            {
                                text4 = "keytypes";
                            }
                            if (text3.ToLower().IndexOf("comments") > 0)
                            {
                                text4 = "comments";
                            }
                        }
                        else
                        {
                            switch (text4)
                            {
                                case "keywords":
                                    list1.Add(text3);
                                    break;
                                case "keytypes":
                                    list2.Add(text3);
                                    break;
                                case "comments":
                                    text2 = text3;
                                    break;
                            }
                        }
                    }
                }
                reader1.Close();
            }
            catch (Exception exception1)
            {
                exception1.ToString();
                text1 = "<span class="errors">There was an error opening file " + pathToDefFile + language.ToString() + ".def...</span>";
                flag1 = false;
                throw new ApplicationException(string.Format("There was an error opening file {0}{1}.def", pathToDefFile, language), exception1);
            }
            if (!flag1)
            {
                return text1;
            }
            int num1 = 0;
            ArrayList list3 = new ArrayList();
            MatchCollection collection1 = Regex.Matches(tmpCode, text2, RegexOptions.Multiline | RegexOptions.IgnoreCase);
            foreach (Match match1 in collection1)
            {
                list3.Add(match1.ToString());
                tmpCode = tmpCode.Replace(match1.ToString(), "[ReplaceComment" + num1++ + "]");
            }
            num1 = 0;
            ArrayList list4 = new ArrayList();
            string text5 = ""((\\")|[^"(\\")]|)+"";
            collection1 = Regex.Matches(tmpCode, text5, RegexOptions.Singleline | RegexOptions.IgnoreCase);
            foreach (Match match2 in collection1)
            {
                list4.Add(match2.ToString());
                tmpCode = tmpCode.Replace(match2.ToString(), "[ReplaceString" + num1++ + "]");
            }
            num1 = 0;
            ArrayList list5 = new ArrayList();
            collection1 = Regex.Matches(tmpCode, "'.*?'", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            foreach (Match match3 in collection1)
            {
                list5.Add(match3.ToString());
                tmpCode = tmpCode.Replace(match3.ToString(), "[ReplaceChar" + num1++ + "]");
            }
            string[] textArray1 = new string[list1.Count];
            list1.CopyTo(textArray1);
            tmpCode = Regex.Replace(tmpCode, @"" + ("(?<replacethis>" + string.Join("|", textArray1) + ")") + @"(?<!//.*)", "<span class="keyword">${replacethis}</span>");
            string[] textArray2 = new string[list2.Count];
            list2.CopyTo(textArray2);
            tmpCode = Regex.Replace(tmpCode, @"" + ("(?<replacethis>" + string.Join("|", textArray2) + ")") + @"(?<!//.*)", "<span class="keytype">${replacethis}</span>");
            num1 = 0;
            foreach (string text8 in list5)
            {
                tmpCode = tmpCode.Replace("[ReplaceChar" + num1++ + "]", "<span class="string">" + text8.ToString() + "</span>");
            }
            num1 = 0;
            foreach (string text9 in list4)
            {
                tmpCode = tmpCode.Replace("[ReplaceString" + num1++ + "]", "<span class="string">" + text9.ToString() + "</span>");
            }
            num1 = 0;
            foreach (string text10 in list3)
            {
                tmpCode = tmpCode.Replace("[ReplaceComment" + num1++ + "]", "<span class="comment">" + text10.ToString() + "</span>");
            }
            tmpCode = Regex.Replace(tmpCode, @"(d{1,12}.d{1,12}|d{1,12})", "<span class="integer">$1</span>");
            if (this.replaceEnter)
            {
                tmpCode = Regex.Replace(tmpCode, " ", "");
                tmpCode = Regex.Replace(tmpCode, " ", "<br />" + Environment.NewLine);
            }
            tmpCode = Regex.Replace(tmpCode, "  ", "  ");
            tmpCode = Regex.Replace(tmpCode, " ", "      ");
            text1 = "<div class="codestuff">" + Environment.NewLine;
            text1 = text1 + "<style type="text/css">" + Environment.NewLine;
            text1 = text1 + "<!--" + Environment.NewLine;
            text1 = text1 + ".codestuff .keytype { color : #FF9933; font-weight : normal; }" + Environment.NewLine;
            text1 = text1 + ".codestuff .keyword { color : #224FFF; font-weight : normal; }" + Environment.NewLine;
            text1 = text1 + ".codestuff .integer { color : #FF0032; }" + Environment.NewLine;
            text1 = text1 + ".codestuff .comment { color : #008100; }" + Environment.NewLine;
            text1 = text1 + ".codestuff .errors { color : #FF0000; font-weight : bold; }" + Environment.NewLine;
            text1 = text1 + ".codestuff .string { color : #FF0022; }" + Environment.NewLine;
            text1 = text1 + "//-->" + Environment.NewLine;
            text1 = text1 + "</style>" + Environment.NewLine;
            text1 = text1 + tmpCode;
            return (text1 + "</div>" + Environment.NewLine);
        }

        public bool ReplaceEnter
        {
            get
            {
                return this.replaceEnter;
            }
            set
            {
                this.replaceEnter = value;
            }
        }

        private bool replaceEnter;
    }
}

如果你的站比较大,那么可能就要修改上传文件的方法,加上自动重命名和分月目录,修改Uploader.cs:
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
 * 
 * Licensed under the terms of the GNU Lesser General Public License:
 *         http://www.opensource.org/licenses/lgpl-license.php
 * 
 * For further information visit:
 *         http://www.fckeditor.net/
 * 
 * "Support Open Source software. What about a donation today?"
 * 
 * File Name: Uploader.cs
 *     This is the code behind of the uploader.aspx page used for Quick Uploads.
 * 
 * File Authors:
 *         Frederico Caldeira Knabben (fredck@fckeditor.net)
 */
using System ;
using System.Globalization ;
using System.Xml ;
using System.Web ;
namespace FredCK.FCKeditorV2
{
    public class Uploader : FileWorkerBase
    {
        protected override void OnLoad(EventArgs e)
        {
            // Get the posted file.
            HttpPostedFile oFile = Request.Files["NewFile"];
            // Check if the file has been correctly uploaded
            if (oFile == null || oFile.ContentLength == 0)
            {
                SendResults(202);
                return;
            }
            int iErrorNumber = 0;
            string sFileUrl = "";
            // Get the uploaded file name.
            //string sFileName = System.IO.Path.GetFileName( oFile.FileName ) ;
            //检查建立分月目录
            string sFolder = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString();
            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(System.IO.Path.Combine(this.UserFilesDirectory, sFolder));
            if (!dir.Exists)
            {
                dir.Create();
            }
            //根据日期和随机数设置自动重命名文件
            Random rd = new Random();
            string sFileName = sFolder + "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(10).ToString();
            int iCounter = 0;
            while (true)
            {
                //防止没有扩展名的处理,弃用内置方法
                string sFileExtension = string.Empty;
                try
                {
                    sFileExtension = oFile.FileName.Substring(oFile.FileName.LastIndexOf('.'), oFile.FileName.Length - oFile.FileName.LastIndexOf('.'));
                }
                catch
                {
                    //Exception ex = new Exception(oFile.FileName);
                    //throw ex;
                    sFileExtension = ".jpg";
                }
                string sFilePath = System.IO.Path.Combine(this.UserFilesDirectory, sFileName) + sFileExtension;

                if (System.IO.File.Exists(sFilePath))
                {
                    iCounter++;
                    sFileName =
                        sFileName +
                        "(" + iCounter + ")" +
                        sFileExtension;
                    iErrorNumber = 201;
                }
                else
                {
                    oFile.SaveAs(sFilePath);
                    sFileUrl = System.IO.Path.Combine(this.UserFilesPath, sFileName + sFileExtension);
                    break;
                }
            }
            SendResults(iErrorNumber, sFileUrl, sFileName);
        }
        SendResults Method
    }
}
然后将重新编译的FredCK.EditerV2.dll也拷贝到cs的bin目录。
接下来将fckeditor的编辑器文件夹拷贝到cs的根目录,修改fckconfig.js
/*
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
 * 
 * Licensed under the terms of the GNU Lesser General Public License:
 *         http://www.opensource.org/licenses/lgpl-license.php
 * 
 * For further information visit:
 *         http://www.fckeditor.net/
 * 
 * "Support Open Source software. What about a donation today?"
 * 
 * File Name: fckconfig.js
 *     Editor configuration settings.
 *     See the documentation for more info.
 * 
 * File Authors:
 *         Frederico Caldeira Knabben (fredck@fckeditor.net)
 */
FCKConfig.CustomConfigurationsPath = '' ;
FCKConfig.EditorAreaCSS = FCKConfig.BasePath + 'css/fck_editorarea.css' ;
FCKConfig.DocType = '' ;
FCKConfig.BaseHref = '' ;
FCKConfig.FullPage = false ;
FCKConfig.Debug = false ;
FCKConfig.AllowQueryStringDebug = true ;
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ;
FCKConfig.PreloadImages = [ FCKConfig.SkinPath + 'images/toolbar.start.gif', FCKConfig.SkinPath + 'images/toolbar.buttonarrow.gif' ] ;
FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;
//添加插件
//FCKConfig.Plugins.Add( 'placeholder', 'zh-cn' ) ;
FCKConfig.Plugins.Add( 'FastSmsTag', 'zh-cn' );     //系统标记插件
FCKConfig.Plugins.Add( 'EYSImageGallery', 'zh-cn' );    //插入媒体
FCKConfig.Plugins.Add( 'InsertCode', 'zh-cn' );    //插入代码
//FCKConfig.Plugins.Add( 'UploadFile', 'zh-cn' );    //插入附件
//FCKConfig.Plugins.Add( 'autogrow' ) ;
//FCKConfig.AutoGrowMax = 400 ;
FCKConfig.ProtectedSource.Add( /<script[sS]*?</script>/gi ) ; // <SCRIPT> tags.
// FCKConfig.ProtectedSource.Add( /<%[sS]*?%>/g ) ;    // ASP style server side code <%...%>
// FCKConfig.ProtectedSource.Add( /<?[sS]*??>/g ) ;    // PHP style server side code
// FCKConfig.ProtectedSource.Add( /(<asp:[^>]+>[s|S]*?</asp:[^>]+>)|(<asp:[^>]+/>)/gi ) ;    // ASP.Net style tags <asp:control>
FCKConfig.AutoDetectLanguage    = false ;
FCKConfig.DefaultLanguage        = 'zh-cn' ;
FCKConfig.ContentLangDirection    = 'ltr' ;
FCKConfig.ProcessHTMLEntities    = true ;
FCKConfig.IncludeLatinEntities    = true ;
FCKConfig.IncludeGreekEntities    = true ;
FCKConfig.FillEmptyBlocks    = true ;
FCKConfig.FormatSource        = true ;
FCKConfig.FormatOutput        = true ;
FCKConfig.FormatIndentator    = '    ' ;
FCKConfig.ForceStrongEm = true ;
FCKConfig.GeckoUseSPAN    = false ;
FCKConfig.StartupFocus    = false ;
FCKConfig.ForcePasteAsPlainText    = false ;
FCKConfig.AutoDetectPasteFromWord = true ;    // IE only.
FCKConfig.ForceSimpleAmpersand    = false ;
FCKConfig.TabSpaces        = 0 ;
FCKConfig.ShowBorders    = true ;
FCKConfig.SourcePopup    = false ;
FCKConfig.UseBROnCarriageReturn    = false ;    // IE only.
FCKConfig.ToolbarStartExpanded    = true ;
FCKConfig.ToolbarCanCollapse    = true ;
FCKConfig.IgnoreEmptyParagraphValue = true ;
FCKConfig.PreserveSessionOnFileBrowser = false ;
FCKConfig.FloatingPanelsZIndex = 10000 ;
FCKConfig.ToolbarLocation = 'In' ;
FCKConfig.ToolbarSets["Default"] = [
    ['Source','DocProps','-','NewPage','Preview','-'],
    ['Cut','Copy','Paste','PasteText','PasteWord'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
    ['OrderedList','UnorderedList','-','Outdent','Indent'],
    ['TextColor','BGColor'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
    ['Link','Unlink','Anchor'],
    ['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak','UniversalKey'],
    ['InsertMedia','InsertReal'],['InsertCode'],
    ['Style','FontFormat','FontName','FontSize'],
    ['FitWindow','-','About']
] ;
FCKConfig.ToolbarSets["Basic"] = [
    ['Source','-','Cut','Copy','Paste','PasteText','PasteWord'],
    ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-'],
    ['Image','Flash','InsertMedia','InsertReal'],['InsertCode','About']
] ;
FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form'] ;
FCKConfig.FontColors = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,808080,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF' ;
FCKConfig.FontNames        = '宋体;隶书;楷体_GB2312;仿宋_GB2312;黑体;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
FCKConfig.FontSizes        = '1/很小;2/较小;3/小;4/中等;5/大;6/较大;7/很大' ;
FCKConfig.FontFormats    = 'p;div;pre;address;h1;h2;h3;h4;h5;h6' ;
FCKConfig.StylesXmlPath        = FCKConfig.EditorPath + 'fckstyles.xml' ;
FCKConfig.TemplatesXmlPath    = FCKConfig.EditorPath + 'fcktemplates.xml' ;
FCKConfig.SpellChecker            = 'ieSpell' ;    // 'ieSpell' | 'SpellerPages'
FCKConfig.IeSpellDownloadUrl    = 'http://iespell.huhbw.com/ieSpellSetup220647.exe' ;
FCKConfig.MaxUndoLevels = 15 ;
FCKConfig.DisableObjectResizing = false ;
FCKConfig.DisableFFTableHandles = true ;
FCKConfig.LinkDlgHideTarget        = false ;
FCKConfig.LinkDlgHideAdvanced    = false ;
FCKConfig.ImageDlgHideLink        = false ;
FCKConfig.ImageDlgHideAdvanced    = false ;
FCKConfig.FlashDlgHideAdvanced    = false ;
// The following value defines which File Browser connector and Quick Upload 
// "uploader" to use. It is valid for the default implementaion and it is here
// just to make this configuration file cleaner. 
// It is not possible to change this value using an external file or even 
// inline when creating the editor instance. In that cases you must set the 
// values of LinkBrowserURL, ImageBrowserURL and so on.
// Custom implementations should just ignore it.
var _FileBrowserLanguage    = 'aspx' ;    // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage    = 'aspx' ;    // asp | aspx | cfm | lasso | php
// Don't care about the following line. It just calculates the correct connector 
// extension to use for the default File Browser (Perl uses "cgi").
var _FileBrowserExtension = _FileBrowserLanguage == 'perl' ? 'cgi' : _FileBrowserLanguage ;
FCKConfig.LinkBrowser = false ;
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ;
FCKConfig.LinkBrowserWindowWidth    = FCKConfig.ScreenWidth * 0.7 ;        // 70%
FCKConfig.LinkBrowserWindowHeight    = FCKConfig.ScreenHeight * 0.7 ;    // 70%
FCKConfig.ImageBrowser = false ;
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ;
FCKConfig.ImageBrowserWindowWidth  = FCKConfig.ScreenWidth * 0.7 ;    // 70% ;
FCKConfig.ImageBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ;    // 70% ;
FCKConfig.FlashBrowser = false ;
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ;
FCKConfig.FlashBrowserWindowWidth  = FCKConfig.ScreenWidth * 0.7 ;    //70% ;
FCKConfig.FlashBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ;    //70% ;
FCKConfig.LinkUpload = true ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/' + _QuickUploadLanguage + '/upload.' + _QuickUploadLanguage ;
FCKConfig.LinkUploadAllowedExtensions    = "" ;            // empty for all
FCKConfig.LinkUploadDeniedExtensions    = ".(php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi)$" ;    // empty for no one
FCKConfig.ImageUpload = true ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/' + _QuickUploadLanguage + '/upload.' + _QuickUploadLanguage + '?Type=Image' ;
FCKConfig.ImageUploadAllowedExtensions    = ".(jpg|gif|jpeg|png)$" ;        // empty for all
FCKConfig.ImageUploadDeniedExtensions    = "" ;                            // empty for no one
FCKConfig.FlashUpload = true ;
FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/' + _QuickUploadLanguage + '/upload.' + _QuickUploadLanguage + '?Type=Flash' ;
FCKConfig.FlashUploadAllowedExtensions    = ".(swf|fla)$" ;        // empty for all
FCKConfig.FlashUploadDeniedExtensions    = "" ;                    // empty for no one
FCKConfig.SmileyPath    = FCKConfig.BasePath + 'images/smiley/msn/' ;
FCKConfig.SmileyImages    = ['regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ;
FCKConfig.SmileyColumns = 8 ;
FCKConfig.SmileyWindowWidth        = 320 ;
FCKConfig.SmileyWindowHeight    = 240 ;主要注意插件的添加和文件上传部分的配置,以及简化工具栏的设置。这个简化版的工具栏可以配合前面提到的快速回复使用哦。
最后,修改cs的web.config,在<appsettings>节加入下面一段
    <!--FCK编辑器配置-->
    <add key="FckEditor:BasePath" value="/FCKeditor/"/>
打开Communityserver.config,修改<core>节相应的为这一段
textEditorType = "Cnfdc.FckForCs.FCK, Cnfdc.FckForCs" 
好了,祈祷一下吧,刷新你的cs,然后到个人资料修改中设置使用的编辑器为:HTML编辑器标准版( 如果看不到的话,就有问题了)
体验一下diy的乐趣吧!
有问题,大家一起探讨!
。
http://www.kwkj.cn/forums/forums/permalink/11144/10736/ShowThread.aspx
摘自<http://www.onlinegf.com/bbs/showpost.asp?threadid=120>
FCKeditor相关资料简介:
官方文档http://wiki.fckeditor.net/
下载地址http://www.fckeditor.net/download/default.html
官方演示http://www.fckeditor.net/demo/default.html
针对于ASP.NET开发者来说,你有两种选择:
1. 只使用FCKeditor,下载http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=75845,然后自行配置其中的几个核心js文件。对此发开不作为本文所讨论的范畴。
2. 使用FCKeditor.Net,下载http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=137125。需要声明的是,这个文件只是一个ASP.NET控件DLL文件,并不包括FCKeditor的编辑器内核。所以你还应该下载上一种方式中提到的文件包。
下面结合一个ASP.NET2.0的项目来具体看看FCKeditor的安装、配置。在开始之前请先下载FCKeditor文件包和FCKeditor.Net 服务器控件。启用VS2005新建一个C#的WEB Site工程,取名FCKPro。
FCKeditor安装:
所谓安装就是一个简单的拷贝过程。
把下载的FCKeditor_2.2.zip文件包直接解压缩到FCKPro的根目录下,这样根目录下就得到一个FCKeditor文件夹,里面富含所有FCKeditor的核心文件。
然后把下载的FCKeditor.Net_2.2.zip随便解压缩到你硬盘的一个空目录,里面是FCKeditor.Net的源代码(基于.NET1.1的C#工程),你可以用VS2003来对它进行再度开发,本文尚不涉及本内容,我们只是直接使用FCKeditor.Net工程目录下的\bin\Release目录中的FredCK.FCKeditorV2.dll文件。
在VS2005中添加对FredCK.FCKeditorV2.dll的引用:
1. 在FCKPro工程浏览器上右键,选择添加引用(Add Reference…),找到浏览(Browse)标签,然后定位到你解压好的FredCK.FCKeditorV2.dll,确认就可以了。这时,FCKPro工程目录下就多了一个bin文件夹,里面包含FredCK.FCKeditorV2.dll文件。当然,你也可以完全人工方式的来做,把FredCK.FCKeditorV2.dll直接拷贝到FCKPro\bin\下面,VS2005在编译时会自动把它编译进去的。
2.        为了方便RAD开发,我们把FCKeditor控件也添加到VS的工具箱(Toolbox)上来,展开工具箱的常用标签组(General),右键选择组件(Choose Items…),在对话框上直接找到浏览按钮,定位FredCK.FCKeditorV2.dll,然后确认就可以了。这时工具箱呈现
我的经验告诉我,这样会省去很多在开发时使用FCKeditor控件时要添加的声明代码。
至此,你已经完成了FCKeditor的安装,并可以在你的项目中使用FCKeditor了,当然后面还有很多需要配置的东西。
FCKeditor在ASP.NET2.0 Web项目中的配置:
现在,我开始来把FCKeditor应用在我们的项目中。打开Default.aspx,切换到设计模式(Design),把FCKeditor控件从工具箱上拖动下来,在Default页上你就可以看到这个FCKeditor了,不过这时只能看到一个FCKeditor的站位框,不会看到运行时的效果,鼠标选中FCKeditor1后,在属性(Property)面板上可以设置这个FCKeditor对象的一些基本属性。比较重要的是BasePath属性,如果先前FCKeditor就定在了根目录的FCKeditor下,就设置成~/FCKeditor/,如果是别的目录名就换成相应的值(注意:控件默认值是/FCKeditor/,因为我们使用的是服务器控件设置了runat="server"属性所以要显式的声明BasePath="~/FCKeditor/")。把Default.aspx切换到源代码模式(Source),我们可以看到IDE自动生成的代码:
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server"></FCKeditorV2:FCKeditor>
如果当初没有把FCKeditor添加到工具箱上,那么应该在添加引用后自己手动来添加这些代码。
在源代码模式下,把鼠标点在FCKeditorV2:FCKeditor标签内容上,它会加粗显示,这时属性面板上显示出了FCKeditor服务器控件的全部属性,比在设计模式时多出了许多。
属性列表:
| 
             AutoDetectLanguage  | 
            
             BaseHref  | 
            
             BasePath  | 
            
             ContentLangDirection  | 
        
| 
             CustomConfigurationsPath  | 
            
             Debug  | 
            
             DefaultLanguage  | 
            
             EditorAreaCSS  | 
        
| 
             EnableSourceXHTML  | 
            
             EnableViewState  | 
            
             EnableXHTML  | 
            
             FillEmptyBlocks  | 
        
| 
             FontColors  | 
            
             FontFormats  | 
            
             FontNames  | 
            
             FontSizes  | 
        
| 
             ForcePasteAsPlainText  | 
            
             ForceSimpleAmpersand  | 
            
             FormatIndentator  | 
            
             FormatOutput  | 
        
| 
             FormatSource  | 
            
             FullPage  | 
            
             GeckoUseSPAN  | 
            
             Height  | 
        
| 
             ID  | 
            
             ImageBrowserURL  | 
            
             LinkBrowserURL  | 
            
             PluginsPath  | 
        
| 
             runat  | 
            
             SkinPath  | 
            
             StartupFocus  | 
            
             StylesXMLPath  | 
        
| 
             TabSpaces  | 
            
             ToolbarCanCollapse  | 
            
             ToolbarSet  | 
            
             ToolbarStartExpanded  | 
        
| 
             UseBROnCarriageReturn  | 
            
             Value  | 
            
             Visible  | 
            
             Width  | 
        
事件列表:
| 
             OnDataBinding  | 
        
| 
             OnDisposed  | 
        
| 
             OnInit  | 
        
| 
             OnLoad  | 
        
| 
             OnPreRender  | 
        
| 
             OnUnload  | 
        
以上属性和事件的使用在此不一一的赘述了,请先自行摸索一下,目前我也没找到相关资料,不过都不是很难,如果你有在asp下使用FCKeditor的经验,应该明白其中一些属性的意义,和fckconfig.js的设置项意义相同。以后有时间我会再把这部分整理好。需要说明的是FCKeditor2.2的fckconfig.js和2.0版本的有了较大改进,体积更小,配置方式也更加灵活,具体请自行下载比较。
针对这个示例我配置的代码如下:
<FCKeditorV2:FCKeditor
ID="FCKeditor1"
runat="server"
AutoDetectLanguage="false"
DefaultLanguage="zh-cn"
BasePath="~/FCKeditor/">
</FCKeditorV2:FCKeditor>
好,现在运行一下这个页面,允许修改Web.Config(这样IDE会自动在工程下添加一个Web.Config文件)。看到效果了吧!
有人会问:怎么得到一个HTTP Error 404 - Not Found.的错误呢?得到这个错误一般是BasePath没有设置正确,参看上述提到的BasePath注意事项仔细检查!
到了这里,FCKeditor的配置并没有真正的完成,因为它里面的一个强大功能我们还没正确配置:文件上传。
在Default.aspx的运行模式下,点FCKeditor的“插入/编辑图像”(又或者是Flash)功能,在弹出框点“浏览服务器”,又弹出一个对话框,此时随即出现的是一个错误提示框XML request error: Forbidden(403).
得到这样的错误有Web开发经验的都知道403应该是读写权限的问题。可是为什么呢?原因在于没有配置UserFiles路径。
我们在FCKPro根目录下,新建一个空目录Files。连同BasePath的设置通常的做法是这样的:
打开FCKPro工程的Web. Config文件,修改appSettings元素,配置如下:
<appSettings>
<add key="FCKeditor:BasePath" value="~/FCKeditor/"/>
<add key="FCKeditor:UserFilesPath" value="/FCKPro/Files" />
</appSettings>
设置了FCKeditor:BasePath后就不用再每次使用FCKeditor实例时指定BasePath属性了,FCKeditor:UserFilesPath则是制定我们所有上传的文件的所在目录。你也许会问为什么要设置成/FCKPro/Files这样而不是~/Files,因为FCKeditor使用这个值来返回你上传后的文件的相对路径到客户端,~/Files的形式是ASP.NET在服务可以编译解释的,但是在客户端的静态就不懂这是什么了。如果使用~/Files后,那么所有上传文件的返回路径都是~/Files形式的,你就会得到这样的链接http://~/Files/Image/logo.gif这样的链接解果就是路径为找到。所以才要我们上述那样设置,这是在开发阶段,如果在工程完成后发布时请记住把/FCKPro/Files改成/Files,道理不说大家也明白,开发阶段VS2005在运行项目时的URL是http://localhost/项目名称/的形式,发布后在Server上建立站点,跟路径就是http://www.abc.com/的形式了,所以发布后一定要改过来。这些地方是在使用FCKeditor2.2+ASP.NET2.0时经常发错误而又莫名其所云的地方。
先不要高兴,这个上传的功能至此还差最关键的一步。在FCKeditor所在根目录下(FCKPro/FCKeditor/)找到fckconfig.js文件,用文本编辑器打开,在大概132行(大概是因为之前您也许参考其它资料更改过这个文件了)的地方找到:
var _FileBrowserLanguage = 'asp' ; // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage = 'asp' ; // asp | aspx | cfm | lasso | php
把这两行赋值代码的值由asp改成aspx,保存关闭这个文件。
好了,大功告成了!在此运行FCKPro项目,使用浏览服务器功能,OK了吧?
再提一下:
对于开发中使用文件上传功能遇到 XML request error: Internal Server Error(500) 错误的解决办法。
遇到500内部错误是怎么回事呢?
因为ASP.NET2.0新增了Theme功能,所以如果在你的工程中你对Web.config使用到了styleSheetTheme或theme的话那就要再多修改一下。
还是到FCKeditor所在的目录,分别打开\editor\filemanager\upload\aspx\upload.aspx和\editor\filemanager\browser\default\connectors\aspx\connector.aspx两个aspx文件,在page标签中添加Theme=""或StyleSheetTheme=""看你在工程使用的是什么就修改什么。修改后如下:
<%@ Page language="c#" Inherits="FredCK.FCKeditorV2.Uploader" AutoEventWireup="false" Theme="" %>
或
<%@ Page language="c#" Inherits="FredCK.FCKeditorV2.Uploader" AutoEventWireup="false" StylesheetTheme="" %>
这样就解决了500的内部错误。
                    
                

                
            
        
浙公网安备 33010602011771号