PHP上fckeditor 2.6.6的使用和配置(完整版)

WBOY
Release: 2016-06-13 10:56:20
Original
1183 people have browsed it

PHP下fckeditor 2.6.6的使用和配置(完整版)

一、下载

1、首先去官网下载FCKeditor2.6.6 多国语言版(可以搜索“FCKeditor 2.6.6, released on 15 February 2010”)。下载地址: http://ckeditor.com/download。

二、精简

按照如下步骤删除其中一些不需要的测试文件:

1.只保留/fckeditor/目录下的fckconfig.js(配置文件)、fckeditor.js(js方式调用文件)、fckeditor.php(php方式调用文件)、fckeditor_php4.php(php4的调用文件)、fckeditor_php5.php(php5的调用文件)、fckstyles.xml(样式)、fcktemplates.xml(模板)文件和editor文件夹七个文件以外的所有文件;

2.删除目录/editor/_source(基本上,所有_开头的文件夹或文件都是可选的);

3.删除/editor/filemanager/connectors/(存放编辑器所支持的Web动态语言)下除了php目录的所有目录;

4.删除/editor/lang/(存放的是多语言配置文件)下的除了 en.js, zh.js, zh-cn.js三个文件的所有文件。

三、设置

1.更改默认语言和编程语言:

打开/fckeditor/fckconfig.js ;(千万注意这个文件是utf-8编码,我第一次编辑的时候保存成了ANSI格式结果出错了,找了好长时间原因)修改->

FCKConfig.AutoDetectLanguage =false;(使其不能根据系统语言自动检测加载相应的语言。)

var FCKConfig.DefaultLanguage = ‘zh-cn’ ;

var _FileBrowserLanguage = ‘php’ ;

var _QuickUploadLanguage = ‘php’ ;

2.开启文件上传的功能:

配置editor\filemanager\connectors\php\config.php

将$Config['Enabled'] = false ;改为$Config['Enabled'] = true ;

更改$Config['UserFilesPath'] = ‘/userfiles/’ ;为你的上传目录(注意:这个目录要存在——自己创建好);

注意:这个目录是相对于主目录的。 也就是说,这个目录是相对于根目录的,注意,如果你在本机上测试,那么,这个根目录就是 http://localhost 。

四、调用

可以按下面的例子在php(例子中的PHP文件放在网站的子目录中)中调用fckeditor编辑器:

include(”../fckeditor/fckeditor.php”);??????? // 包含fckeditor类,fckeditor目录放在网站根目录下

$BasePath = “/fckeditor/”;??????????? // 编辑器路径

$oFCKeditor = new FCKeditor(’CreMer’);??? // 创建一个fckeditor对象,表单的名称为CreMer

$oFCKeditor->BasePath? = $BasePath;

$oFCKeditor->Value? = ‘test’;??????? // 设置表单初始值

// 还可设置以下部分(“=”包含部分),并非必须:

//==================================================================================//

$oFCKeditor->Width = ‘800′;??????????? // 编辑器宽度,类中有默认值,如果不想修改可不管此项

$oFCKeditor->Height= ‘300′;??????????? // 同width,此处为高$oFCKeditor->ToolbarSet

$oFCKeditor->ToolbarSet = ‘Basic’;??????? // 默认编辑器工具栏有Basic(基本工具)和Default(所有工具)两种选择,另外还可以自己建立工具栏

$oFCKeditor->Config['SkinPath'] = ‘/fckeditor/editor/skins/silver/’;??????? // 设置编辑器皮肤

//==================================================================================//

$oFCKeditor->Create();??????????? // 调用类中方法,必须

用$_POST['CreMer']就能获取文本框里面的值。

说明:

//包含fckeditor类

include(”../fckeditor/fckeditor.php”) ;

//设置编辑器路径

$sBasePath = “fckeditor/”;

//创建一个Fckeditor,表单的txtarea名称为content

$oFCKeditor = new FCKeditor(’content’) ;

$oFCKeditor->BasePath = $sBasePath ;

//设置表单初始值

$oFCKeditor->Value = ‘This is some sample text’ ;

$oFCKeditor->Create() ;

//设置长宽

$oFCKeditor->Width

$oFCKeditor->Height

$oFCKeditor->ToolbarSet

五、其他例子

?

六、其他技巧

1.修改工具栏按钮:

这样做主要是为了提高安全性,减少一般用户可以使用的功能:

FCKConfig.ToolbarSets["MyStyle"] = [

['Source','Preview','FitWindow','-','Templates'],

['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],

['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],

['ShowBlocks'],

‘/’,

['Bold','Italic','Underline','StrikeThrough','TextColor','BGColor'],

['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'],

['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],

['Link','Unlink','Anchor'],

‘/’,

['Style','FontFormat','FontName','FontSize']

??? // No comma for the last row.

] ;

或者更改

FCKConfig.ToolbarSets["Basic"] = [

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

] ;

在设置后,调用时添加这个语句:

$oFCKeditor->ToolbarSet?= ‘MyStyle’ ;

2.上传中文名文件时显示乱码怎么办

在文件connectors/php/commands.php中查找:

$sFileName = $oFile['name'] ;

在后面添加一行:

$sFileName = iconv(”utf-8″,”gbk”,$sFileName);

3、修正文件列表时中文文件名显示乱码问题

在文件connectors/php/util.php中查找:

return ( utf8_encode( htmlspecialchars( $value ) ) ) ;

修改为:

return iconv(”,’utf-8′,htmlspecialchars( $value ));

4、修正新建中文文件夹时的文件夹名乱码问题

?

在文件connectors/php/commands.php中查找:

$sNewFolderName =

在后面添加一行:

$sNewFolderName = iconv(”utf-8″,”gbk”,$sNewFolderName);

2.6.3版及后续版本的fck下的html文件已经加了utf-8的文件头。

5.给文章添加不同的样式

6、配置皮肤。

“fckeditor\editor\skins\”目录中有default、office2003、silver等风格可供选择。

打开/fckeditor/fckconfig.js ;修改->

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

7、在编辑器域内可以使用Tab键。

打开/fckeditor/fckconfig.js ;修改(1为是,0为否)->

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

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

打开/fckeditor/fckconfig.js ;修改->

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

9、修改默认的显示字体

可以通过修改样式表来达到要求,打开/editor/css/fck_editorarea.css,修改font-size属性即可。

10、在上传文件窗口点击浏览服务器出错

可能会出现“the server didn’t send back a proper xml…..??”的错误提示。

因为FCKeditor要求不同类型的文件分别传到不同的目录,包括file,image,falsh,media 等目录,可以先建立起来试试。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!