Home Backend Development PHP Tutorial FCKeditor的PHP配备

FCKeditor的PHP配备

Jun 13, 2016 am 10:59 AM
php

FCKeditor的PHP配置

1、下载FCKeditor 多国语言版

2、解压后为文件夹减肥:

删除/FCKeditor/目录下除fckconfig.js, fckeditor.js, fckstyles.xml, fcktemplates.xml,fckeditor.php五个文件以外的所有文件
删除目录/editor/_source,_testcases(基本上,所有_开头的文件夹或文件都是可选的),
删除/editor/filemanager/browser/default/connectors/下除PHP目录的所有目录
删除/editor/filemanager/upload/下的除PHP目录的所有目录
删除/editor/lang/下的除了 en.js, zh.js, zh-cn.js三个文件的所有文件
3.
打开/FCKeditor/fckconfig.js
修改
var FCKConfig.DefaultLanguage = 'zh-cn' ;
var _FileBrowserLanguage? = 'php' ;
var _QuickUploadLanguage? = 'php' ;
要开启文件上传的话,还需要配置FCKeditor\editor\filemanager\upload\php\config.php以及\ FCKeditor\editor\filemanager\browser\default\connectors\php\config.php
(上传中文名文件会乱码)

4.调用方法
将FCKeditor放在网站根目录
在PHP文件里面,包含/FCKeditor/fckeditor.php文件
//包含fckeditor类
include("../FCKeditor/fckeditor.php") ;
//设置编辑器路径
$sBasePath = "/FCKeditor/";;//这个路径一定要和上面那个引入路径一致,否则会报错:找不到fckeditor.html页面
//创建一个Fckeditor,表单的名称为ipaddr
$oFCKeditor = new FCKeditor('ipaddr') ;//ipaddr即为这个标签的name,可以用$_POST['ipaddr']获得编辑器的内容
$oFCKeditor->BasePath? = $sBasePath ;
//设置表单初始值
$oFCKeditor->Value? = 'This is some sample text' ;
$oFCKeditor->Create() ;//注意:若用到模板(如smarty)则$fck = $oFCKeditor->CreateHtml();然后把$fck抛给模板

//还可设置
$oFCKeditor->Width
$oFCKeditor->Height
$oFCKeditor->ToolbarSet

5.定制
a.定制调用路径
直接将FCKeditor目录改为editor/,并且在调用的时候指定根路径为/editor/。
b.定制风格
可以通过修改editor\skins目录下的Skin来定制风格,主要是修改CSS。
c.定制toolbar

在fckconfig.js中,默认定制好了Default,Basic两种toolbar,你也可以根据格式定制自己的toolbar,并且在php中使用$oFCKeditor->ToolbarSet=toolbarname调用

d.定制字体
将fckconfig.js里面的FCKConfig.FontNames字体列表前面加上:
宋体;黑体;隶书;楷体_GB2312;
(注意保存为UTF8格式)

e.关闭文件上传
i. 将fckconfig.js里面的FCKConfig.LinkBrowser,FCKConfig.ImageBrowser, FCKConfig.FlashBrowser,FCKConfig.LinkUpload,FCKConfig.ImageUpload,FCKConfig.FlashUpload 设置为false.
ii.直接将filemanager里面的php文件删降
iii.定制toolbars
最重要的一点,你需要更改filemanager下面的php文件,只有认证的用户才可以访问。

f.注意事项:请用Editplus之类的编辑器编辑配置文件,注意保存格式为utf8.

?

?

?

?

?

?

?

?


/////////////////////////////////////////////////////////

?

有人会问:怎么得到一个HTTP Error 404 - Not Found.的错误呢?得到这个错误一般是BasePath没有设置正确,参看上述提到的BasePath注意事项仔细检查!

到了这里,FCKeditor的配置并没有真正的完成,因为它里面的一个强大功能我们还没正确配置:文件上传。

在Default.aspx的运行模式下,点FCKeditor的“插入/编辑图像”(又或者是Flash)功能,在弹出框点“浏览服务器”,又弹出一个对话框,此时随即出现的是一个错误提示框XML request error: Forbidden(403).

得到这样的错误有Web开发经验的都知道403应该是读写权限的问题。可是为什么呢?原因在于没有配置UserFiles路径。

我们在FCKPro根目录下,新建一个空目录Files。连同BasePath的设置通常的做法是这样的:

打开FCKPro工程的Web. Config文件,修改appSettings元素,配置如下:


?

?


设置了FCKeditor:BasePath后就不用再每次使用FCKeditor实例时指定BasePath属性了,FCKeditor:UserFilesPath则是制定我们所有上传的文件的所在目录。你也许会问为什么要设置成/FCKPro/Files这样而不是~/Files,因为FCKeditor使用这个值来返回你上传后的文件的相对路径到客户端,~/Files的形式是ASP.NET在服务可以编译解释的,但是在客户端的静态就不懂这是什么了。如果使用~/Files后,那么所有上传文件的返回路径都是~/Files形式的,你就会得到这样的链接http://~/Files/Image/logo.gif这样的链接解果就是路径为找到。所以才要我们上述那样设置,这是在开发阶段,如果在工程完成后发布时请记住把/FCKPro/Files改成/Files,道理不说大家也明白,开发阶段VS2005在运行项目时的URL是http://localhost/项目名称/的形式,发布后在Server上建立站点,跟路径就是http://www.abc.com/的形式了,所以发布后一定要改过来。这些地方是在使用FCKeditor2.2+ASP.NET2.0时经常发错误而又莫名其所云的地方。

先不要高兴,这个上传的功能至此还差最关键的一步。在FCKeditor所在根目录下(FCKPro/FCKeditor/)找到fckconfig.js文件,用文本编辑器打开,在大概132行(大概是因为之前您也许参考其它资料更改过这个文件了)的地方找到:

?

var _FileBrowserLanguage??? = 'asp' ;????? // asp | aspx | cfm | lasso | perl | php | py

var _QuickUploadLanguage = 'asp' ;????? // asp | aspx | cfm | lasso | php

?

把这两行赋值代码的值由asp改成aspx,保存关闭这个文件。

好了,大功告成了!在此运行FCKPro项目,使用浏览服务器功能,OK了吧?

?

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles