FCKeditor2.6.3配置(转)

1. 程序删减(可选)

下载下来的FCKEditor2.6.3中,很多文件我们不需要放到我们的程序中,我们需要留下的有根目录下:
editor目录 、fckconfig.js、 fckeditor.php、fckeditor_php5.php、fckpackager.xml、fckeditor.js、 fckstyles.xml、fcktemplates.xml、license.txt 这几个保留,其余的全部去除;
子目录下:
editor"filemanager"connectors目录中 把php目录留下(上传用什么方法就留下什么),其余的方法目录删除(注意留下test.html 和 uploadtest.html)
editor"lang 语言目 把 en.js 、 zh.js 、 zh-cn.js 留下,其余全部删除

2.修改 fckeditor/fckconfig.js



①确认以下两值为php(fckeditor 2.6.3下已默认为php):
     var _FileBrowserLanguage = 'php'
     var _QuickUploadLanguage = 'php'
②修改变量以下值:
FCKConfig.AutoDetectLanguage = true ; //如果你的用户是多语言环境,请设为true,如果只是中文用户,改为false
FCKConfig.DefaultLanguage = 'zh-cn' ;
//添加中文字体
FCKConfig.FontNames = '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
FCKConfig.FontSizes   = '9px;10px;11px;12px;13px;14px;16px;18px;24px;36px' ;
③在IE中直接回车是产生一个p标签,这样两行间距太大,如果用SHIFT+ENTER这样就是产生BR标签.间距不大,不过这样太麻烦了,那么我们把他们替换下。
FCKConfig.EnterMode = 'br' ; // p | div | br
FCKConfig.ShiftEnterMode = 'p' ;     // p | div | br

3.启用php文件上传功能

打开/fckeditor/editor/filemanager/connectors/php/config.php
找到:
         $Config['Enabled'] = false
         改成:
         $Config['Enabled'] = true

         设置上传存放目录:
         找到:
         $Config['UserFilesPath'] = '/userfiles/'
         改成:
         $Config['UserFilesPath'] = '你自己的项目路径'
通过上面的方法我们配置好了后,我们测试上传功能,上传英文名字的文件没有问题,但如果文件名有汉字,那么会出现乱码,可有两种解决方案,一种是让上传支 持中文名,使用这种方案可能会出现文件名重复的现象,另外中文文件名的下载会有些问题;另一种是用当前时间戳做为文件名,下面针对两种方案给出实现,可根 据具体情况进行选择。

方案一 让fckeditor在php环境中支持中文名上传
打开fckeditor/editor/filemanager/connectors/php/commands.php
找到
$sFileName = $oFile['name'] ;
改为
   $sFileName = iconv("utf-8","gbk",$oFile['name']) ;

方案二 使用当前时间戳做为文件名
打开fckeditor/editor/filemanager/connectors/php/commands.php
找到
$sFileName = $oFile['name'] ;
改为
$sFileName = time().".".strtolower(array_pop(explode(".",$oFile['name'])));

以上方案可任选一种,推荐使用方案二

4. 自定义工具栏, 修改fck菜单样式设置

在默认情况下,FCKeditor会调用上面定义的所有工具栏按钮。大家可以根据自己的需求进行设置。表1对上面的配置选项功能说明进行汇总。

代码名称 功能 代码名称 功能    
Source 源代码 DocProps 页面属性    
- |分隔符 Save 保存    
NewPage 新建 Preview 预览    
Templates 模板 Cut 剪切    
Copy 复制 Paste 粘贴    
PasteText 粘贴为无格式文本 PasteWord 从MS Word粘贴    
Print 打印 SpellCheck 拼写检查    
Undo 撤消 Redo 重做    
Find 查找 Replace 替换    
SelectAll 全选 RemoveFormat 清除格式    
Form 表单 Checkbox 复选框    
Radio 单选框 TextField 单行文本    
Textarea 多行文本 Select 列表菜单    
Button 按钮 ImageButton 图像域    
HiddenField 隐藏域 Bold 加粗    
Italic 倾斜 Underline 下划线    
StrikeThrough 删除线 Subscript 下标    
Superscript 上标 OrderedList 插入/删除编号列表    
UnorderedList 插入/删除项目列表 Outdent 减少缩进    
Indent 增加缩进 JustifyLeft 左对齐    
JustifyCenter 居中对齐 JustifyRight 右对齐    
JustifyFull 两端对齐 Link 插入/编辑链接    
Unlink 取消链接 Anchor 插入/编辑锚点链接    
Image 插入编辑图像 Flash 插入/编辑Flash    
Table 插入/编辑表格 Rule 插入水平线    
Smiley 插入表情 SpecialChar 插入特殊符号    
PageBreak 插入分页 Style 样式    
FontFormat 格式 FontName 字体    
FontSize 大小 TextColor 文本颜色    
BGColor 背景颜色 FitWindow 全屏编辑  

5. 指定不同类型的文件上传到不同的目录中

打开fckeditor"editor"filemanager"connectors"php"config.php,重置以下项
$Config['QuickUploadPath']['File']= $Config['UserFilesPath'] .'file/';
$Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] .'image/' ;
$Config['QuickUploadPath']['Flash'] = $Config['UserFilesPath'] .'flash/';
$Config['QuickUploadPath']['Media'] = $Config['UserFilesPath'] .'media/';
这样可以把附件,图片,flash,媒体上传不同的目录中,如果想进一步细化,在这些目录下分年月做下一级目录,上面4项可重置为
$Config['QuickUploadPath']['File'] = $Config['UserFilesPath'] .'file/'.date('Ymd').'/';
$Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] . 'image/'.date('Ymd').'/';
$Config['QuickUploadPath']['Flash'] = $Config['UserFilesPath'] .'flash/'.date('Ymd').'/';
$Config['QuickUploadPath']['Media'] = $Config['UserFilesPath'] .'media/'.date('Ymd').'/';

6.引入在线编辑器时只需:
<?php
include("fckeditor/fckeditor.php") ;
$oFCKeditor = new FCKeditor('FCKeditor1') ;//实例化
$oFCKeditor->BasePath = 'fckeditor/';//这个路径一定要和上面那个引入路径一致,否则会报错:找不到fckeditor.html页面
//$oFCKeditor->Value = '' ;
$FCkeditor->ToolbarSet='Default';     //工具按钮设置
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '300' ;
$oFCKeditor->Create() ;
?>

结合smarty模板用如下代码:
<?php
include_once("FCKeditor/fckeditor.php");
$fck=new FCKeditor('content');     //post/get中数据的字段名称
$fck->BasePath='FCKeditor/';   //路径地址
$fck->ToolbarSet='Default';   //工具栏
$fck->Width='95%';
$fck->Height='450px';
$fck->Value="";
$FCKeditor = $fck->CreateHtml();
$tpl->assign("FCKeditor",$FCKeditor);

?>

 

$oFCKeditor->Create() ; 为输出。。

posted @ 2009-04-02 19:08  般若随风  阅读(939)  评论(2编辑  收藏  举报