首页 | PHP资讯 | 技术专栏 | 资源共享 | PHP培训 | PHP职场 | 图书 | PHP ON WIN | PHP圈子 | PHPer学习大本营
返回列表 回复 发帖

ZF与FCKeditor集成完全攻略(包括上传、浏览服务器图像)

ZF与FCKeditor集成完全攻略(包括上传、浏览服务器图像)

本帖最后由 七月十五 于 2009-5-15 14:06 编辑

太长了,懒得重写,请访问:
http://www.phpeye.com/bbs/viewthread.php?tid=117&extra=page%3D1
PHP5 研究中心
http://blog.csdn.net/haohappy2004/
PHPEye开源社区
phpeye.com

帮你转个帖

FCKedtior是目前最流行和最强大的HTML在线编辑器之一,非常好用。本文介绍如何集成Zend framework和FCKeditor。

首先基本配置的修改,网上很多文章都有写,在此不再多说,最权威的资料当然是FCKeditor官网的:
http://wiki.fckeditor.net/Developer%27s_Guide/Integration/PHP

最主要是修改fckconfig.js文件。

下面说说和ZF的集成,以及一些需要注意的地方:

1。FCKeditor的安装
FCKeditor需要放在public的目录,即通过网站可以访问到的目录下。比如wwwroot/js/FCKeditor。

新版的FCKeditor需要加载一些配置XML文件,所以在你的Apache配置中,XML文件不能转向到ZF的bootstrap。
另外,下面的一些功能需要用到一些PHP文件,而在ZF项目中通常禁用对PHP文件的直接访问。

这些你都可以通过修改Apache服务器的URL重写规则来搞定:
RewriteCond %{REQUEST_URI} !^.*(\.html|\.xml|\.css|\.js|\.gif|\.png|\.jpg|\.jpeg)$|.*(FCKeditor).*

这样,XML文件不转向至index.php,而访问地址中包含FCKeditor字符的php文件也能直接访问。


2。集成

在你的模板文件中(即ZF的View部分,例如views/article/articleForm.php),需要添加表单的地方加入以下代码:

[复制PHP代码] [ - ]
PHP代码如下:

<?php
    $oFCKeditor
= new FCKeditor('ArticleBody'
) ;
   
$oFCKeditor->BasePath = "/js/FCKeditor/"
;
   
$oFCKeditor->Width  = '600'
;
   
$oFCKeditor->Height = '500'
;
    if(
$this->article->ArticleBody!=''
){
        
$oFCKeditor->Value = $this->article->ArticleBody
;
    }else{
        
$oFCKeditor->Value = ''
;
    }
   
$oFCKeditor->Create
();
   
?>




这个表单可以同时用于添加和编辑文章,当文章内容不为空(即当前操作为编辑时),显示文章内容,否则为新增文章,表单内容为空。

提交本页面后,你可以使用$_POST['ArticleBody']来获取表单中的文字内容。


2。浏览服务器图像
在写文章的时候,希望可以直接浏览服务器上的图像,添加到文章里,就需要这个功能。
FCKeditor中本功能的实现在FCKeditor\editor\filemanager\browser\default\connectors\php目录的几个文件。

我们只需要修改
FCKeditor\editor\filemanager\browser\default\connectors\php\config.php

[复制PHP代码] [ - ]
PHP代码如下:
$Config['Enabled'] = true ; //一定要设定成true,本功能才启用
$Config['UserFilesPath'] = '/UserFiles/' ;  //图像文件所在的目录,你可以根据自己的需要修改





设定好后你可以通过ftp上传图像文件到/UserFiles/image目录下,测试一下是否可以浏览。

注意:默认情况下,FCKeditor的图像文件要放在UserFiles下的image目录里,而不能直接放在UserFiles目录里。

3。图像上传

如果你想在写文章的时候,直接上传图像到服务器,然后插入到文章中,可以用这个功能。
FCKeditor中本功能的实现在FCKeditor\editor\filemanager\upload\php目录的几个文件。

我们也只需要修改该目录下的config.php

[复制PHP代码] [ - ]
PHP代码如下:
$Config['Enabled'] = true ;
$Config['UserFilesPath'] = '/UserFiles/' ; //上传目录的路径,通常和上面的浏览部分的路径设成一样的
$Config['UseFileType'] = true ;  //不同上传文件类型是否分目录放置,图像文件会自动被上传到/UserFiles/image目录下,Flash则在/UserFiles/flash目录下





注意:UserFiles目录和其下的image目录要可写权限。
我加入一个不错的PHP群: groupphp@hotmail.com

TOP

还是上传不了啊

TOP

不错帮顶 我也刚刚集成到smarty 感觉FCK还真不错

TOP

报错

Warning: Zend_Loader::include_once(FCKeditor.php) [function.Zend-Loader-include-once]: failed to open stream: No such file or directory in E:\ZendFramework-1.6.0RC2\ZendFramework-1.6.0RC2\library\Zend\Loader.php on line 83

Warning: Zend_Loader::include_once() [function.include]: Failed opening 'FCKeditor.php' for inclusion (include_path='.;../library;../application/default/models/;.;c:\php\includes;E:\ZendFramework-1.6.0RC2\ZendFramework-1.6.0RC2\library') in E:\ZendFramework-1.6.0RC2\ZendFramework-1.6.0RC2\library\Zend\Loader.php on line 83

Fatal error: Class 'FCKeditor' not found in D:\wamp\www\f\application\default\views\scripts\index\add.phtml on line 37
不知道是哪错了 帮忙分析一下

TOP

将FCKeditor写成一个Zend_Form_Element 就好了

TOP

呵。收藏了。以后可能会用到。

TOP

收藏了。

TOP

返回列表