免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 849 | 回复: 0
打印 上一主题 下一主题

最新版的fckeditor2.4在php环境下的设置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-18 10:11 |只看该作者 |倒序浏览
在看过刚刚转载过的一篇文章之后,我按照文中所提的方法进行了实测,发现最新版的fckeditor2.4与之前2.0的配置有较多不同,这里我就将自己的一些经验和大家分享一下,希望能够对新手有些许帮助。
根据我所在官方网站(http://www.fckeditor.net/)所下载zip包来看,fckeditor2.4默认支持的语言是asp,所以对使用asp的朋友不必进行大的调整。而如果使用的是php,则需要对目录结构和配置文件进行一些更改。
首先是目录的设置,选定你的根目录,这里我假设就是站点的根目录 /
则在这个目录下,先解压下载的fckeditor的文件夹,命名为
fckeditor,然后再在根目录下建立一个与/fckeditor平行的文件夹/userfiles,注意"userfiles"这个文件名时配置文件所认可的文件夹的名称,所以不能随意更改(若要更改就必须同时更改配置文件中的相关参数)。
最后在根目录下建立一个/admin目录,这个目录中存放你用来调用
fckeditor得主程序。
这样在主目录下我们就有三个目录:
/
fckeditor     //编辑器存放目录
/userfiles     //文件上传目录
/admin         //用户程序目录

接下来要做的就是修改配置文件:
/fckeditor/fckconfig.js,
/fckeditor/editor/filemanager/browser/default/connectors/php/config.php
/fckeditor/editor/filemanager/upload/php/config.php
首先看如何修改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 sample text. You are using FCKeditor.' ;
$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  /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://localhost/admin/test.php应该就能够看到编辑器正常运行的效果。
还有两点需要补充:
在前面转载的
fckeditor的配置文章中提到要进行简体中文的设置,在新版本的fckeditor2.4种不需要进行这种配置。
而其在前面的文章中还提到:“安装我文章里面的设置,上传路径设置为UserFiles/,但是上传图片文件时,FCKeditor都自动把文件上传到UserFiles/image目录下面,自做主张的建立了一个image目录,很是不爽。”
我看是前面的作者大概是一时间没有完全搞清楚/userfiles这个文件夹并不是简简单单就是一个图片上传的文件夹,同时这个文件夹里面还要存放其他多种媒体文件,例如:flash,image等,这些文件存放在/userfiles下的子目录里面,相当于是给上传给服务器的文件进行了分类,呵呵~


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/51146/showart_402880.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP