zoukankan      html  css  js  c++  java
  • FCKeditor.Net 2.6.3 配置说明与文件精简

    FCKeditor是一个功能强大支持所见即所得功能的文本编辑器,可以为用户提供微软office软件一样的在线文档编辑服务。它不需要安装任何 形式的客户端,兼容绝大多数主流浏览器,支持ASP.Net、ASP、ColdFusion 、PHP、Java、Active-FoxPro、Lasso、Perl、ython 等编程环境。

    官方网站 http://www.fckeditor.net/

    官方文档 http://wiki.fckeditor.net/

    下载地址 http://www.fckeditor.net/download/default.html

    FCKeditor安装和配置

    下载FCKeditor2.63.zip和FCKeditor.NET2.63版的2个zip包

    (a)   FCKeditor_2.6.3是html文件、Javascript文件和图片等资源文件

    (b)   FCKeditor.Net_2.6.3.zip是一个ASP.NET控件DLL文件

    Asp.Net项目中添加对 FCKeditor 的引用

    1. 项目上选择添加引用(Add Reference…),找到 浏览(Browse)标签,然后定位到你解压好的FredCK.FCKeditorV2.dll,确认就可以了

    2. 为了方便RAD开发,可以把FCKeditor控件也添加到VS的工具箱(Toolbox)上来,展开工具箱的常用标签组(General),右键选择组 件(Choose Items…),在对话框上直接找到浏览按钮,定位FredCK.FCKeditorV2.dll,然后确认就可以了

    3. 配置Web.Config,在<appSettings>节点添加,如下所示:

    <appSettings>
    <add key="FCKeditor:BasePath" value="~/Web/fckeditor/"/>
    <add key="FCKeditor:UserFilesPath" value="~/Web/Upload/" />
    </appSettings>

    FCKeditor 的配置:

    进入FCKeditor文件夹,编辑 fckconfig.js 文件

    1、修改:

    var _FileBrowserLanguage = ‘php’ ; // asp | aspx | cfm | lasso | perl | php | py

    var _QuickUploadLanguage = ‘php’ ; // 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、配置皮肤,有default、office2003、silver风格等,可以使用默认。

    FCKConfig.SkinPath = FCKConfig.BasePath + ’skins/default/’ ;

    4、在编辑器域内可以使用Tab键。(1为是,0为否)

    FCKConfig.TabSpaces = 0 ; 改为 FCKConfig.TabSpaces = 1 ;

    5、加上几种常用的字体:

               FCKConfig.FontNames = ‘宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana’;

    6、编辑器域内默认的显示字体为12px,想要修改可以通过修改样式表来达到要求,打开/editor/css/fck_editorarea.css,修改font-size属性即可

    7、关于安全性

    如果你的编辑器用在前台非认证的情况下,推荐使用Basic的toolbar

    FCKConfig.ToolbarSets["Basic"] = [

      ['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink','Image','-','About']

    ] ;

    8、在上传文件窗口点击浏览服务器,可能会出现 the server didn’t send back a proper xml….. 错误提示,是因为FCKeditor要求不同类型的文件分别传到不同的目录,包括file,image,falsh,media 等目录,可以先建立起来试试。

    FCKEditor.NET 2.6 的安全性配置

    文件上传,一直是容易被利用的攻击通道,呵呵,所以这里要重点提一下:

    打开 editor/filemanager/connectors/aspx/config.ascx

    private bool CheckAuthentication()
    {
    //为了防止任意用户均可以打开上传页或者浏览服务器文件
    //建议将此处和你的后台管理权限进行集成,如果不需要验证,则直接返回 true 即可
    //------------------------------------------------

    //1. 假设你用 session 存储用户的登录验证信息,假设 session 的 key 为 auth
    // 则需要返回
    //return (Session["auth"] != null && Session["auth"] == "验证值");

    //2. 如果你用 FORM 验证方式,则可以验证
    //return Page.User.Identity.IsAuthenticated;

    // 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;
    }

    FCKeditor的精简和清理

    进入FCKeditor文件夹,把所有“_”开头的文件和文件夹删掉,这些都是一些范例,只保留editor文件夹、fckconfig.js、fckeditor.js、fckstyles.xml、fcktemplates.xml就可以了;

    进入editor文件夹,删掉“_source”文件夹,里面放的同样是源文件;

    退回上一级目录进入filemanager文件夹,有browser和upload两个文件夹。进入browser"default"connectors,只保留aspx文件夹,其余的删掉;mcpuk目录亦可删除;upload也一样,只保留aspx文件夹;

    退到editor再进入images文件夹,smiley里面放的是表情图标,有msn和fun两个系列,如果你想用自己的表情图标,可以把它们都删除;如果你想用这里的表情图标那就不要删了;

    lang里面放的是语言包,如果只是用简体中文,那么只保留fcklanguagemanager.js、zh-cn.js两个文件就行了,建议也 保留en.js(英文)、zh.js(繁体中文)两个文件,fcklanguagemanager.js是语言配置文件,有了它才能和 fckconfig.js里的设置成对,对应上相应的语言文件,一定要保留!

    再退出lang文件夹,进入skins文件夹,如果你想使用FCKeditor默认的奶黄色,那就把除了default文件夹外的另两个文件夹直接删除,如果想用别的,那就看你自己的喜好了。


     在ToolbarSets中可设置显示的工具
    可去掉About

    配置选项:

    AutoDetectLanguage=true/false 自动检测语言

    Basehref="" _fcksavedurl="""" 相对链接的基地址

    ContentLangDirection="ltr/rtl" 默认文字方向

    ContextMenu=字符串数组,右键菜单的内容

    CustomConfigurationsPath="" 自定义配置文件路径和名称

    Debug=true/false 是否开启调试功能,这样,当调用FCKDebug.Output()时,会在调试窗中输出内容

    DefaultLanguage="" 缺省语言

    EditorAreaCss="" 编辑区的样式表文件

    EnableSourceXHTML=true/false 为TRUE时,当由可视化界面切换到代码页时,把HTML处理成XHTML

    EnableXHTML=true/false 是否允许使用XHTML取代HTML

    FillEmptyBlocks=true/false 使用这个功能,可以将空的块级元素用空格来替代

    FontColors="" 设置显示颜色拾取器时文字颜色列表

    FontFormats="" 设置显示在文字格式列表中的命名

    FontNames="" 字体列表中的字体名

    FontSizes="" 字体大小中的字号列表

    ForcePasteAsPlainText=true/false 强制粘贴为纯文本

    ForceSimpleAmpersand=true/false 是否不把&符号转换为XML实体

    FormatIndentator="" 当在源码格式下缩进代码使用的字符

    FormatOutput=true/false 当输出内容时是否自动格式化代码

    FormatSource=true/false 在切换到代码视图时是否自动格式化代码

    FullPage=true/false 是否允许编辑整个HTML文件,还是仅允许编辑BODY间的内容

    GeckoUseSPAN=true/false 是否允许SPAN标记代替B,I,U标记

    IeSpellDownloadUrl=""下载拼写检查器的网址

    ImageBrowser=true/false 是否允许浏览服务器功能

    ImageBrowserURL="" 浏览服务器时运行的URL

    ImageBrowserWindowHeight="" 图像浏览器窗口高度

    ImageBrowserWindowWidth="" 图像浏览器窗口宽度

    LinkBrowser=true/false 是否允许在插入链接时浏览服务器

    LinkBrowserURL="" 插入链接时浏览服务器的URL

    LinkBrowserWindowHeight=""链接目标浏览器窗口高度

    LinkBrowserWindowWidth=""链接目标浏览器窗口宽度

    Plugins=object 注册插件

    PluginsPath="" 插件文件夹

    ShowBorders=true/false 合并边框

    SkinPath="" 皮肤文件夹位置

    SmileyColumns=12 图符窗列数

    SmileyImages=字符数组 图符窗中图片文件名数组

    SmileyPath="" 图符文件夹路径

    SmileyWindowHeight 图符窗口高度

    SmileyWindowWidth 图符窗口宽度

    SpellChecker="ieSpell/Spellerpages" 设置拼写检查器

    StartupFocus=true/false 开启时FOCUS到编辑器

    StylesXmlPath="" 设置定义CSS样式列表的XML文件的位置

    TabSpaces=4 TAB键产生的空格字符数

    ToolBarCanCollapse=true/false 是否允许展开/折叠工具栏

    ToolbarSets=object 允许使用TOOLBAR集合

    ToolbarStartExpanded=true/false 开启是TOOLBAR是否展开

    UseBROnCarriageReturn=true/false 当回车时是产生BR标记还是P或者DIV标记

    解决FCKEditor上传时中文文件名的方法

    主要是修改文件frmUpload.html文件.用记事本打开frmUpload.html,另存为UTF-8格式即可.

    上传文件自动改名:打开FileBrowser文件夹中的FileWorkerBase.cs文件。
    sFileName = System.IO.Path.GetFileName( oFile.FileName );
    sFileName = this.SanitizeFileName( sFileName );
    string sExtension = System.IO.Path.GetExtension( oFile.FileName );
    sExtension = sExtension.TrimStart( '.' );
    修改为:

    sFileName = System.IO.Path.GetFileName( oFile.FileName );
    sFileName = this.SanitizeFileName( sFileName );
    string sExtension = System.IO.Path.GetExtension(oFile.FileName );
    sExtension = sExtension.TrimStart( '.' ); Random ro = new Random();
    sFileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +
    DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + ateTime.Now.Second.ToString() + ro.Next(99, 1000) + "." + sExtension;

    FCKeditor在web.config中有多项设置:

    view plaincopy to clipboardprint?
    <appSettings>  
    <!--FCKeditor设置(主要是以下两项)-->  
    <!--FCKeditor编辑器路径-->  
    <add key="FCKeditor:BasePath" value="/FCKeditor/"/>  
    <!--FCKeditor用户附件上传路径-->  
    <add key="FCKeditor:UserFilesPath" value="/Resources/TempUpload/"/>  
    </appSettings>  

    <appSettings> <!--FCKeditor设置(主要是以下两项)--> <!--FCKeditor编辑器路径--> <add key="FCKeditor:BasePath" value="/FCKeditor/"/> <!--FCKeditor用户附件上传路径--> <add key="FCKeditor:UserFilesPath" value="/Resources/TempUpload/"/> </appSettings>
      用户登录后通过FCKeditor上传文件则要放置在用户共用上传路径“/Resources/UserUpload/”+“用户邮箱地址”, 如“/Resources/UserUpload/user@gmail.com”。FCKeditor.net获取上传路径文件是:FileWorkerBase.cs,打开找到以下部分

    view plaincopy to clipboardprint?
    protected string UserFilesPath   
         {   
          get  
           {   
            if ( sUserFilesPath == null )   
             {   
              // 第一回从Application["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式   
               sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;   
      
              // 第二回从Session["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式   
              if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
               {   
                 sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;   
                   
                // 第三回从web.config中读取,如果没有尝试其它方式   
                if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
                 {   
                   sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;   
                     
                  // 第四回从DEFAULT_USER_FILES_PATH(这个变量在同文件中)中读取,如果没有尝试其它方式   
                  if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
                     sUserFilesPath = DEFAULT_USER_FILES_PATH ;   
      
                  // 第五回从网址参数ServerPath中读取   
                  if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )   
                   {   
                     sUserFilesPath = Request.QueryString["ServerPath"] ;   
                   }   
      
                 }   
               }   
      
              // Check that the user path ends with slash ("/")   
              if ( ! sUserFilesPath.EndsWith("/") )   
                 sUserFilesPath += "/" ;   
             }   
            return sUserFilesPath ;   
           }   
         }  

    protected string UserFilesPath {           

      get {if ( sUserFilesPath == null )

          {     // 第一回从Application["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式               

            sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"] ;                

              // 第二回从Session["FCKeditor:UserFilesPath"] 中读取,如果没有尝试其它方式               

            if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )               

            {

               sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"] ;                                   

              // 第三回从web.config中读取,如果没有尝试其它方式                 

               if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )                 

              {                   

                sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;

                // 第四回从DEFAULT_USER_FILES_PATH(这个变量在同文件中)中读取,如果没有尝试其它方式                   

                if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )

                  sUserFilesPath = DEFAULT_USER_FILES_PATH ; 

                 // 第五回从网址参数ServerPath中读取                   

                if ( sUserFilesPath == null || sUserFilesPath.Length == 0 )                    

                 {                      sUserFilesPath = Request.QueryString["ServerPath"] ;                   

                 }                  

              }               

            }                

            // Check that the user path ends with slash ("/")               

             if ( ! sUserFilesPath.EndsWith("/") )                 

              sUserFilesPath += "/" ;             

            }             

            return sUserFilesPath ;           

          }         

         }   

      从上面的注释可以看到用户上传路径的顺序,只要在页面加载的时候设置下Session["FCKeditor:UserFilesPath"]就可以设置FCKeditor上用户上传路径了

      view plaincopy to clipboardprint?
      protected void Page_Load(object sender, EventArgs e)   
      {   
        if (!Page.IsPostBack)   
        Session["FCKeditor:UserFilesPath"] = "用户上传路径";   
      }  

      protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) Session["FCKeditor:UserFilesPath"] = "用户上传路径"; }
      (我在配置的时候关闭了文件浏览,只提供文件快速上传)但是在使用的时候如果“Resources/UserUpload/user@gmail.com”中的user@gmail.com路径没创建,上传中FCKeditor它不会创建,也导致了文件无法上传成功,那就需要再修改FCKeditor.net项目中的Uploader.cs文件,添加一段文件夹存在的检测代码,如果不存在用户指定的文件夹侧创建一个 
  • 相关阅读:
    stenciljs 学习四 组件装饰器
    stenciljs 学习三 组件生命周期
    stenciljs 学习二 pwa 简单应用开发
    stenciljs ionic 团队开发的方便web 组件框架
    stenciljs 学习一 web 组件开发
    使用npm init快速创建web 应用
    adnanh webhook 框架 hook rule
    adnanh webhook 框架 hook 定义
    adnanh webhook 框架request values 说明
    adnanh webhook 框架execute-command 以及参数传递处理
  • 原文地址:https://www.cnblogs.com/cwy173/p/1673315.html
Copyright © 2011-2022 走看看