FCKeditor使用方法小结

来源:互联网 发布:红中麻将源码 编辑:程序博客网 时间:2024/05/01 17:17

 


 

用法:1.我的网站目录是www.里面有如下文件夹和文件
  /www
      add.php
      /include
      /FCKeditor

        2.调用FCKeditor的方法:
          (1)在开头包含include("FCKeditor/fckeditor.php")
          (2)在需要使用的的方加入
                       $oFCKeditor = new FCKeditor('FCKeditor1') ;//建立对象
            $oFCKeditor->BasePath = 'FCKeditor/' ;//FCKeditor所在的位置
            $oFCKeditor->ToolbarSet = 'Default' ;//工具按钮
            $oFCKeditor->Create('EditorDefault', '60%',150) ;
           ?> 
            (此处basepath的路径一定要和上面include的路径一样.否则会找不到文件)
            另外,对于这个输入内容的变量,如果要把它存入数据库,它的变量名为你建
            立对象的名字.例如上面就是FCKeditor1 

         3.在FCKeditor/_samples/里面有个php调用的例子.如simples01.php
           和sampleposteddata.php这两个.后面那个文件是输出变量名的php
           程序,通过这个程序可以得到文本输入框内容的变量名.

         4.配置 FCKeditor的toolbar功能按钮可以很容易地进行定制,你可以依据你
           的需要在FCKeditor的配置文件FCKeditor/fck_config.js中进行定制
           ,一个功能按钮对应一个唯一的名称。 
           在fck_config.js中默认情况下已经设定好三种toolbar样式:Default(包
           含全部功能),Accessibility和Basic。
让我们先来看看toolbar样式的定制格式:
config.ToolbarSets["ToolBarSetName"] = [ // Toolbar名
['Item 1','Item 2','-','Item 3','Item n'], // Toolbar第一行
['Item 4','-','Item 5','Item 6','Item n'] // Toolbar第二行
] ;
这里'-'的作用是创建一个分割条。
FCKeditor1.6为我们提供了60个编辑功能,具体功能如下: 

功能名称
含义
功能名称
含义
EditSource
显示HTML源代码
StrikeThrough
删除线
Save
保存
Subscrīpt
下标
NewPage
新建空白页面
Superscrīpt
上标
Preview
预览
JustifyLeft
左对齐
Cut
剪切
JustifyCenter
居中对齐
Copy
复制
JustifyRight
右对齐
Paste
粘贴
JustifyFull
两端对齐
PasteText
纯文本粘贴
InsertOrderedList
自动编号
PasteWord
来自Word的粘贴
InsertUnorderedList
项目符号
Print
打印
Outdent
减少缩进
SpellCheck
拼写检查
Indent
增加缩进
Find
查找
ShowTableBorders
显示表格线
Replace
替换
ShowDetails
显示明细
Undo
撤销
Form
添加Form动作
Redo
还原
Checkbox
复选框
SelectAll
全选
Radio
单选按钮
RemoveFormat
去除格式
Input
单行文本框
Link
插入/编辑 链接
Textarea
滚动文本框
RemoveLink
去除连接
Select
下拉菜单
Anchor
锚点
Button
按钮
Image
插入/编辑 图片
ImageButton
图片按钮
Table
插入/编辑 表格
Hidden
隐藏
Rule
插入水平线
Zoom
显示比例
SpecialChar
插入特殊字符
FontStyleAdv
系统字体
UniversalKey
软键盘
FontStyle
字体样式
Smiley
插入表情符号
FontFormat
字体格式
About
关于
Font
字体
Bold
粗体
FontSize
字体大小
Italic
斜体
TextColor
文字颜色
Underline
下划线
BGColor
背景色


    默认的Default包含了FCKeditor的全部功能,个人感觉有些功能用不上,完全加载还会影响显示速度,所以我简化了一下,只加载了一些常用的功能:
1、打开FCKeditor/fck_config.js文件,添加如下代码
config.ToolbarSets["www"] = [
['EditSource','Save','NewPage','Preview','-','Cut','Copy','Paste','PasteText','-','Find','Replace','-','Undo','Redo','-','SelectAll','-','Link','RemoveLink','-','Image','Table','Rule','SpecialChar','Smiley'] ,
['Bold','Italic','Underline','-','JustifyLeft','JustifyCenter','JustifyRight','-','InsertOrderedList','InsertUnorderedList','-','Form','Checkbox','Radio','Input','Textarea','Select','Button','-','FontStyleAdv','TextColor'] ] ;
 
  这样加载的速度就快多了。
  使用时只需把$oFCKeditor->ToolbarSet = 'Default' 
  改为$oFCKeditor->ToolbarSet = 'www' 即可

           最后.我们把FCKeditor目录下所有以下划线“_”开头的目录都删掉以节省空间,如_test._samples,等等.完工

原创粉丝点击