最新版的fckeditor2.4在php环境下的设置

在看过刚刚转载过的一篇文章之后,我按照文中所提的方法进行了实测,发现最新版的fckeditor2.4与之前2.0的配置有较多不同,这里我就将自己的一些经验和大家分享一下,希望能够对新手有些许帮助。


根据我所在官方网站(http://www.fckeditor.net/)所下载zip包来看,fckeditor2.4默认支持的语言是asp,所以对使用asp的朋友不必进行大的调整。而如果使用的是php,则需要对目录结构和配置文件进行一些更改。


首先是目录的设置,选定你的根目录,这里我假设就是站点的根目录 /
则在这个目录下,先解压下载的fckeditor的文件夹,命名为fckeditor,然后再在根目录下建立一个与


最后在根目录下建立一个/admin目录,这个目录中存放你用来调用


首先看如何修改


还有两点需要补充:
在前面转载的


而其在前面的文章中还提到:

 

安装我文章里面的设置,上传路径设置为UserFiles/,但是上传图片文件时,FCKeditor都自动把文件上传到UserFiles/image目录下面,自做主张的建立了一个image目录,很是不爽。

我看是前面的作者大概是一时间没有完全搞清楚/userfiles这个文件夹并不是简简单单就是一个图片上传的文件夹,同时这个文件夹里面还要存放其他多种媒体文件,例如:flash,image等,这些文件存放在
/userfiles下的子目录里面,相当于是给上传给服务器的文件进行了分类,呵呵~ 
fckeditor的配置文章中提到要进行简体中文的设置,在新版本的fckeditor2.4种不需要进行这种配置。
fckconfig.js:
在文件中找到一下两行:
var _FileBrowserLanguage     = 'asp' ;     // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage     = 'asp' ;     // asp | aspx | cfm | lasso | php
将这两行中的asp分别用php代替,如下:
var _FileBrowserLanguage     = 'php' ;     // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage     = 'php' ;     // asp | aspx | cfm | lasso | php
这样,
fckeditor在执行编辑器命令时,自动调用早已经包含在文件夹中的php程序,而不是默认的asp程序。

接下来要修改
/fckeditor/editor/filemanager/browser/default/connectors/php/config.php
在该文件中找到这样一行:
$Config['Enabled'] = false ;   
将其改为:
$Config['Enabled'] = true ;


最后还要修改:
/fckeditor/editor/filemanager/upload/php/config.php
同样的要将此配置文件的:
$Config['Enabled'] = false ;改为
$Config['Enabled'] = true ;
这样,php文件中的文件上传功能才得以用php语言来解析。

至此,
fckeditor基本配置完毕。为了进行测试,我引用一段代码:
在/admin文件夹中建立以下文件:
test.php和testsubmit.php
test.php
文件内容如下:
<?php
//引入在线编辑器
include("../FCKeditor/fckeditor.php");
?>
<html>
     <head>
         <title>FCKeditor - Sample</title>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <meta name="robots" content="noindex, nofollow">
         <link href="../sample.css" rel="stylesheet" type="text/css" />
     </head>
     <body>
     <h1>FCKeditor - PHP - Sample</h1>
         This sample displays a normal HTML form with an FCKeditor with full features
         enabled.
         <hr>
     <form action="testsubmit.php" method="post" target="_blank">
<?php
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// $oFCKeditor->BasePath = '/fckeditor/' ;     // '/fckeditor/' is the default value.
//建立
fckeditor对象
$oFCKeditor = new FCKeditor('FCKeditor1');
$oFCKeditor->BasePath = '../fckeditor/';
$oFCKeditor->ToolbarSet = 'Default';
$oFCKeditor->InstanceName = 'EditorDefault' ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '400' ;
$oFCKeditor->Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ;
$oFCKeditor->Create() ;
?>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>



testsubmit.php内容如下:
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
*   - GNU General Public License Version 2 or later (the "GPL")
*     http://www.gnu.org/licenses/gpl.html
*
*   - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
*     http://www.gnu.org/licenses/lgpl.html
*
*   - Mozilla Public License Version 1.1 or later (the "MPL")
*     http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* File Name: sampleposteddata.php
*      This page lists the data posted by a form.
*
* File Authors:
*          Frederico Caldeira Knabben (www.fckeditor.net)
*          Jim Michaels (jmichae3@yahoo.com)
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
     <head>
         <title>FCKeditor - Samples - Posted Data</title>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <meta name="robots" content="noindex, nofollow">
         <link href="../sample.css" rel="stylesheet" type="text/css" />
     </head>
     <body>
         <h1>FCKeditor - Samples - Posted Data</h1>
         This page lists all data posted by the form.
         <hr>
         <table width="100%" border="1" cellspacing="0" bordercolor="#999999">
             <tr style="FONT-WEIGHT: bold; COLOR: #dddddd; BACKGROUND-COLOR: #999999">
                 <td nowrap>Field Name&nbsp;&nbsp;</td>
                 <td>Value</td>
             </tr>
<?php

if ( isset( $_POST ) )
    $postArray = &$_POST ;             // 4.1.0 or later, use $_POST
else
    $postArray = &$HTTP_POST_VARS ;     // prior to 4.1.0, use HTTP_POST_VARS

foreach ( $postArray as $sForm => $value )
{
     if ( get_magic_quotes_gpc() )
         $postedValue = htmlspecialchars( stripslashes( $value ) ) ;
     else
         $postedValue = htmlspecialchars( $value ) ;

?>
             <tr>
                 <td valign="top" nowrap><b><?=$sForm?></b></td>
                 <td width="100%"><?=$postedValue?></td>
             </tr>
<?php
}
?>
         </table>
     </body>
</html>

这样,在服务器中运行文件http:/test.php应该就能够看到编辑器正常运行的效果。
fckeditor得主程序。
这样在主目录下我们就有三个目录:
/
fckeditor    //编辑器存放目录
/userfiles    //文件上传目录
/admin        //用户程序目录

接下来要做的就是修改配置文件:

/fckeditor/fckconfig.js,

/fckeditor/editor/filemanager/browser/default/connectors/php/config.php
/fckeditor/editor/filemanager/upload/php/config.php
/fckeditor平行的文件夹/userfiles,注意"userfiles"这个文件名时配置文件所认可的文件夹的名称,所以不能随意更改(若要更改就必须同时更改配置文件中的相关参数)。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值