zoukankan      html  css  js  c++  java
  • 那些年,我还在学习使用FCK

    那些年做asp.net开发时,时常会用到FCKEditor,FCK是一个强大的编译器,在web开发中时常使用到,不仅可以对文件进行编辑,而且可以上传图片与视频,但是在上传时也有一些地方需要修改,主要是对session的控件,这样可以安全一点

    一、FCK在asp.net中的使用

    1、下载fck编译器,js文件与.dll文件,加入到.net的项目中  

     

    2、在.net的配置文件中添加配置节,指明fck的js目录与上传路径

      <appSettings>

    <add key="FCKeditor:BasePath" value="~/fckeditor/"/>

    <add key="FCKeditor:UserFilesPath" value="~/UploadFiles/"/>

    </appSettings>

    3、将Fck添加到页面上,它与在其它的页面上使用不同,FCK在.net中作为一个控件使用,直接拖到页面中就可以使用了,代码如下:  

     <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FckTest.aspx.cs" Inherits="FckTest" %> 

    <%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>

    <!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="FCKeditor2" runat="server" Height="500" Width="600">

    </FCKeditorV2:FCKeditor>

    </div>

    </form>

    </body>

    </html>

    4、运行结果:

    5、Session设置

    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 false;

    HttpSessionState tempSession = System.Web.HttpContext.Current.Session;

    if (tempSession["UserID"] != null)

    return true;

    else

    return false;

    }

    目录文件:jcceditor\editor\filemanager\connectors\aspx\UploadFile\config.ascx 

    二、FCKeditor添加鼠标右键菜单

    1、  找到fckeditor中的\fckeditor\editor\lang下的zh-cn.js,按文件中的样式,添加一个自已需要的标签,例如:Fillin: "设为填空",这样就只设置了这个东东,并没有显示在右键中;

    2、  这一是很关键的一步,需要找到fckeditor中的fckeditor\editor\js下 fckeditorcode_gecko.js文件,这个文件是非IE的浏览器,若是IE就修改对应的文件fckeditorcode_ie.js;

    3、  在fckeditorcode_gecko.js中找到FCK_ContextMenu_GetListener(A),在  menu.AddItem('Paste', FCKLang.Paste, 9, FCKCommands.GetCommand('Paste').GetState() == -1);这一句后面添上自定义的按钮的代码:

    menu.AddItem('Fillin', FCKLang.Fillin, 10, FCKCommands.GetCommand

    ('Fillin').GetState() == FCK_TRISTATE_DISABLED); //* modify whc by 2010 07

    4、  找到该文件下的FCKCommands.GetCommand这一行,添加一个case语句,其新建一个对象,来自自定义,如:case 'Fillin': B = new FCKFillinCommand();//* modify whc by 2010 07

    5、 这一步,大家都很清楚了,就是添加上对应的命令,同样是在些文件下,找到添加

    命令的位置,把自定义的命令加上去就可以了,如:

    找到:FCKDialogCommand,在些添加我们的代码,

    var FCKFillinCommand = function() {//* whc modify by 2010

    this.Name = 'Fillin';

    };

    FCKFillinCommand.prototype.Execute = function() {

    FCKUndo.SaveUndoStep();

    if (this.IsActive) FCKStyles.RemoveStyle("_FCK_Fillin");

    else FCKStyles.ApplyStyle("_FCK_Fillin");//我们这里强行给了一个样式名(StyleName)

    FCK.Focus();

    FCK.Events.FireEvent('OnSelectionChange');

    // alert("你点击了设为填空!!!");

    };

    FCKFillinCommand.prototype.GetState = function() {

    return (FCK.FillinMode == 0 ? 0 : 1);

    };

    6、 修改样式,在fckeditor中找到fckconfig.js,添加一个样式,当然应前面几个步骤对应,找到FCKConfig.CoreStyles这个位置添加:如:

       'Fillin': { Element: 'strong',Styles : { 'color' : 'Red' }, Overrides: 'b' },

    7、 测试结果:

    行了,右键加好了!!!

    三、FCKeditor添加一个工具菜单

    1、 同样是在zh-cn.js中添加一个你所想要的按钮和名称;

    2、 在fckconfig.js中找到fckconfig.toolbarsets[“basic”]或者FCKConfig.

    ToolbarSets["Default"],在其中添加你定义的按钮,也就是zh-cn..js中的那个;

    如:['Cut', 'Copy', 'Paste', 'PasteText', 'PasteWord', '-', 'Fillin'],或者

    ['Bold', 'Italic', '-', 'OrderedList', 'UnorderedList', '-', 'Link', 'Unlink', '-', 'About', 'Fillin'] //*whc 2010 modify

    3、  找到FCKToolbarItems.GetItem(其在fckeditorcode_gecko.js)中,添加一个case语句,这里与添加右键菜单的位置不同,其实差不多;如:     case 'Fillin':

      B = new FCKToolbarButton('Fillin', FCKLang.Fillin, null, null, true, null, 100); break;

    4、实例化方法,这与前面的添加的右键菜单一样,同样是要实例command对应的方法;

    5、测试效果

    四、FCKeditor修改原有的菜单

    1、 这里以修改字体大小为例,首先,若你需要修改其前面“大小”字符,则就要选择lang中zh-cn文件,修改’ FontSize: "填空设置",’;

    2、 在fckeditor的fckconfig.js文件中删出你所不需要的选项;

     如:

      FCKConfig.FontSizes       = '是否填空' ;//whc modify 2010 07 27

       Styles     : { 'font-size' : 'large' },

    总结

      那些年开始慢慢接近项目,FCK就是很好用的一个html编译器,此文以回忆那些年使用FCK的日子。

  • 相关阅读:
    ipa在线下载安装(itms-services)
    linux环境下无文件执行elf
    Linux Running State Process ".so"、"code" Injection Technology
    VS2013本地C++单元测试框架
    vs的环境变量
    利用rundll32执行程序的函数执行程序
    动态so注入
    ELF运行时注入
    MailKit系列之转发电子邮件
    WPF实战之一 桌面消息框(右下角消息弹出框)
  • 原文地址:https://www.cnblogs.com/xin_ny/p/2381113.html
Copyright © 2011-2022 走看看