FCKeditor 2.6及FCKEditor asp.net设置

[ 1682 查看 / 3 回复 ]

FCKeditor相关资料简介: 官方网站http://www.fckeditor.net/ 官方文档http://wiki.fckeditor.net/ 下载地址http://www.fckeditor.net/download/default.html 官方演示http://www.fckeditor.net/demo/default.html 如何在FCKeditor 2.6中添加插入视频和音频功能参考地址: http://bbs.lehu.shu.edu.cn/Article.aspx?aid=20112  http://www.wilf.cn/post/550.html  http://blog.csdn.net/xinma/archive/2007/09/15/1785948.aspx   FCKEditor asp.net设置 下载:http://www.fckeditor.net (要下载FCKeditor2.6.zipFCKeditor.NET2.5版的2zip包) FCKeditor2.6zip是其最新的Javascript文件和图片等; FCKeditor.NET.zip是一个ASP.NET控件DLL文件。 下面结合一个ASP.NET2.0的项目来具体看看FCKeditor的安装、配置、使用。在开始之前请先下载FCKeditor文件包和FCKeditor.Net 服务器控件。启用VWD2005新建一个C#WEB Site工程,取名FCKPro FCKeditor安装: 所谓安装就是一个简单的拷贝过程。把下载的FCKeditor2.4.2.zip文件包直接解压缩到FCKPro的根目录下,这样根目录下就得到一个FCKeditor文件夹,里面富含所有FCKeditor的核心文件。 然后把下载的FCKeditor.Net.zip随便解压缩到你硬盘的一个空目录,里面是FCKeditor.Net的源代码,你可以对它进行再度开发,本文尚不涉及本内容,我们只是直接使用其目录下的"bin"Debug目录中的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详细的设置: 进入FCKeditor文件夹,编辑 fckconfig.js 文件。 1此步骤是必须的,也是最重要的一步。 修改 var _FileBrowserLanguage = 'asp' ; // asp | aspx | cfm | lasso | perl | php | py var _QuickUploadLanguage = 'asp' ; // asp | aspx | cfm | lasso | php 改为 var _FileBrowserLanguage = 'aspx' ; // asp | aspx | cfm | lasso | perl | php | py var _QuickUploadLanguage = 'aspx' ; // asp | aspx | cfm | lasso | php 2、配置语言包。有英文、繁体中文等,这里我们使用简体中文。 修改 FCKConfig.DefaultLanguage = 'en' ; FCKConfig.DefaultLanguage = 'zh-cn' ; 3、配置皮肤。有defaultoffice2003silver风格等,这里我们可以使用默认。 FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/default/' ; 4、在编辑器域内可以使用Tab键。(1为是,0为否) FCKConfig.TabSpaces = 0 ; 改为FCKConfig.TabSpaces = 1 ; 5、加上几种我们常用的字体的方法,例如: 修改 FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ; FCKConfig.FontNames = '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' 6、编辑器域内默认的显示字体为12px,想要修改可以通过修改样式表来达到要求,打开/editor/css/fck_editorarea.css,修改font-size属性即可。如font-size: 14px; 7、关于安全性。 如果你的编辑器用在网站前台的话,那就不得不考虑安全了,在前台千万不要使用Defaulttoolbar,要么自定义一下功能,要么就用系统已经定义好的Basic,也就是基本的toolbar 修改 FCKConfig.ToolbarSets["Basic"] = [     ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','-','About'] FCKConfig.ToolbarSets["Basic"] = [ ['Bold','Italic','-','OrderedList','UnorderedList','-',/*'Link',*/'Unlink','-','Style','FontSize','TextColor','BGColor','-','Smiley','SpecialChar','Replace','Preview'] ] ; 这是我改过的Basic,把图像功能去掉,把添加链接功能去掉,因为图像和链接和flash和图像按钮添加功能都能让前台页直接访问和上传文件,要是这儿不改直接给你上传个木马还不马上玩完? 当然也可以配置一下WebConfig,也能让它确保安全,接下来我们将讲到。 FCKPro工程项目的设置: 1、配置WebConfig,在<appSettings>节点添加,如下所示: <appSettings>     <add key="FCKeditor:BasePath" value="/项目名称/fckeditor/"/>   //Win2003下,Files目录一定要有IIS_WPG用户的写权限,否则可能无法上传     <add key="FCKeditor:UserFilesPath" value="/项目名称/Files/" /> </appSettings> 说明:BasePathfckeditor所在路径,fckeditor由于我们直接放网站目录下这样写就可以,如果您的网站多放几层适当调整即可。UserFilesPath是所有上传的文件的所在目录。我们新建了一个Files文件夹放在了项目中做为上传文件的所在目录,这里为了方便,但由于考虑到安全性,我们建议Files要单独做wwwroot目录下的一个站点比较好,和我们的站点FCKEditor平行。不要把它放FCKEditor里,为什么呢?因为Files是要让客户有写的权限的,如果放FCKEditor下很危险。Files目录要有写的权限。你根据自己网站需求设置那个帐号,本文为方便设置User实际中你可能用ASP.NET帐号更合理。 2、在FCKpro工程项目中编写一个最简单的页面 <%@ Page Language="C#"  AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" validateRequest="false" %> <%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %> // 这里要主要两个参数 // 默认为<%@ Page Language="C#"  AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> // 我们要添加一个参数 validateRequest=false,否则提交带html代码的内容会报错 // 从客户端(...)中检测到有潜在危险的 Request.Form 值。 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>无标题页</title> </head> <body>     <form id="form1" runat="server">     <div>         <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server">         </FCKeditorV2:FCKeditor>         </div>     </form> </body> </html> 如何获取其内容呢?读取FCKeditor1控件的Value属性值即可。 FCKEditor 2.6的问题: 1.FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法 打开editor/filemanager/connectors/aspx/config.ascx修改CheckAuthentication()方法,返回true C# code private bool CheckAuthentication() { // WARNING : DO NOT simply return "true". By doing so, you are allowing // "anyone" to upload and list the files in your server. You must implement // some kind of session validation here. Even something very simple as // //        return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true ); // // where Session[ "IsAuthorized" ] is set to "true" as soon as the // user logs in your system.         return true; } 2.在上传文件窗口点击浏览服务器,会出现the server didn't send back a proper xml.....错误提示,因为后期版本的FCKEditor要求不同类型的文件分别传到不同的目录,包括file,image,falsh,media等目录,一定要先建立起来。 FCKeditor精简版的制作方法(附)  进入FCKeditor文件夹,把所有“_”开头的文件和文件夹删掉,这些都是一些范例,只保留editor文件夹、fckconfig.jsfckeditor.jsfckstyles.xmlfcktemplates.xml就可以了;   进入editor文件夹,删掉“_source”文件夹,里面放的同样是源文件;   退回上一级目录进入filemanager文件夹,有browserupload两个文件夹。进入browser"default"connectors,只保留aspx文件夹,其余的删掉;mcpuk目录亦可删除;upload也一样,只保留aspx文件夹;   退到editor再进入images文件夹,smiley里面放的是表情图标,有msnfun两个系列,如果你想用自己的表情图标,可以把它们都删除;如果你想用这里的表情图标那就不要删了;   lang里面放的是语言包,如果只是用简体中文,那么只保留fcklanguagemanager.jszh-cn.js两个文件就行了,建议也保留en.js(英文)、zh.js(繁体中文)两个文件,fcklanguagemanager.js是语言配置文件,有了它才能和fckconfig.js里的设置成对,对应上相应的语言文件,一定要保留!   再退出lang文件夹,进入skins文件夹,如果你想使用FCKeditor默认的奶黄色,那就把除了default文件夹外的另两个文件夹直接删除,如果想用别的,那就看你自己的喜好了。 至此,文件精简完毕,由原来的2.55M变成现在的797K了。接着修改设置。
分享 转发
TOP

附件: FCKeditor263.rar (2008-8-25 15:26:31, 1433.45 K)
该附件被下载次数 67

TOP

FCKEditor目前的最新版本是2.6,但支持.NET的DLL版本还是2.5,本文介绍FCKEditor2.6在ASP.NET中的配置方法。 本文的示例下载地址(包含了整个解决方案及网站,下载后即可使用): FCKEditor官方下载地址:http://www.fckeditor.net/download 配置方法如下: 一、在官方网站上下载 解压后目录结构如下图所示: 二、删除不必要的文件 从官方下载下来的FCKEditor2.6大小有3.61M(解压后),其实有很多文件对于只用ASP.NET的来讲是不需要的,我们可以删除不必要的文件: 站长.站 1.根目录下除editor目录、fckconfig.js、fckeditor.js  fckstyles.xml  fcktemplates.xml 这几个保留,其余的全部删除 2.editor\filemanager\connectors目录中除aspx目录外全部删除 3.editor\lang目录中除en.js、zh.js 、zh-cn.js外全部删除 4.删除_samples目录,当然如果你想看示例,就不要删除这个目录了。 三、FCKEditor2.6的详细设置 1.fckconfig.js中修改 FCKConfig.ToolbarSets["Default"] = [ ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'], ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'], '/', ['Style','FontFormat','FontName','FontSize'], ['TextColor','BGColor'], ['FitWindow','ShowBlocks','-','About']  // No comma for the last row. ] ; //上面一段我去掉了一些不常用的功能,可以根据实际需要增加。 [panel]中国站长_站,为中文网站提供动力[/panel] FCKConfig.DefaultLanguage  = 'zh-cn' ;    //原来是en var _FileBrowserLanguage = 'aspx' ; // asp | aspx | cfm | lasso | perl | php | py  改成aspx var _QuickUploadLanguage = 'aspx' ; // asp | aspx | cfm | lasso | perl | php | py 2.在Bin中加入DLL文件 DLL文件下载地址: 3.在工具栏中加入DLL文件 4.配置上传路径 编辑FCKeditor\editor\filemanager\connectors\aspx\config.aspx 中修改 private bool CheckAuthentication() { // WARNING : DO NOT simply return "true". By doing so, you are allowing // "an*" to upload and list the files in your server. You must implement // some kind of session validation here. Even something very simple as... 中国.站.长站 // //  return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true ); // // ... where Session[ "IsAuthorized" ] is set to "true" as soon as the // user logs in your system. return true; //原来这里是 false;不过还是建议看看上面的警告 } 在SetConfig方法中设置 UserFilesPath = "~/Upload/FCKEditor";//我这里设置在了网站根目录下的Upload/FCKEditor目录中,根据实际情况和个人喜好而定。 本文的示例下载地址(包含了整个解决方案及网站,下载后即可使用):
TOP

哦了















圆通快递
TOP