免费注册 查看新帖 |

Chinaunix

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

fckeditor集成到php zend framework框架中 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-01 18:02 |只看该作者 |倒序浏览
我们要做的是把Fckeditor写成一个Zend Framework 插件形式..这样就可以让整个站点调用到FCK... 这样无论是前台和后台都行
1.获得fckeditor 编辑器。我用的是2.6.3版本,解压后放在public/scripts目录下
很多文件我们不需要放到我们的程序中,可以删除:
  editor目录 、fckconfig.js、 fckeditor.php、fckeditor_php5.php、fckpackager.xml、fckeditor.js、 fckstyles.xml、
fcktemplates.xml、license.txt这几个保
留,其余的全部去除;
  子目录下:editor\filemanager\connectors目录中 把php目录留下(上传用什么方法就留下什么),其余的方法目录删
除(注意留下test.html 和 uploadtest.html)
  editor\lang语言 把 en.js 、 zh.js 、 zh-cn.js 留下,其余全部删除2.修改 fckeditor/fckconfig.js
①确认以下两值为php(fckeditor 2.6.3下已默认为php):var _FileBrowserLanguage = 'php'
     var _QuickUploadLanguage = 'php'②修改变量以下值:FCKConfig.AutoDetectLanguage = true ; //如果你的用户是多语言环境,请设为true,如果只是中文用户,改为false
FCKConfig.DefaultLanguage = 'zh-cn' ;
//添加中文字体
FCKConfig.FontNames = '宋体;黑体;隶书;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
FCKConfig.FontSizes   = '9px;10px;11px;12px;13px;14px;16px;18px;24px;36px' ;③在IE中直接回车是产生一个p标签,这样两行间距太大,如果用SHIFT+ENTER这样就是产生BR标签.间距不大,不过这样太麻烦了,那么我们把他们替换下。FCKConfig.EnterMode = 'br' ; // p | div | br
FCKConfig.ShiftEnterMode = 'p' ;     // p | div | br3.把fckeditor与zf整合
把Fckeditor里面的fckeditor_php5.php这个文件写成如下插件形式,将其放在application/models/下,命名为Fckeditor.php/**此代码为类代码*/
   class Model_Fckeditor extends Zend_Controller_Plugin_Abstract   //要继承这个类
{
/**
  * Name of the FCKeditor instance.
  *
  * @access protected
  * @var string
  */
public $InstanceName ;
/**
  * Path to FCKeditor relative to the document root.
  *
  * @var string
  */
public $BasePath ;
/**
  * Width of the FCKeditor.
  * Examples: 100%, 600
        ………………
    //后面的代码是和FCK里fckeditor_php5.php文件一样的.
4.把/Scripts/目录下关闭重写,建立.htaccess文件内容:RewriteEngine off(不关闭重写会导至调不到FCK文件,发生Zend_Controller_Dispatcher_Exception异常)5.在控制层文件中对调用fckeditorpublic function indexAction()
     {
         // action body
   //Zend_Loader::loadClass('Model_Fckeditor');
      //实例化这个类
      $oFCKeditor = new Model_Fckeditor('content');
   //这里是您放置FCK文件的路径.您要根据您自己的作改动啊
     $oFCKeditor->BasePath = $this->view->baseUrl().'/scripts/fckeditor/';
     //FCK皮肤
     $oFCKeditor->Config['SkinPath'] =$this->view->baseUrl().'/scripts/fckeditor/editor/skins/office2003/';
     $oFCKeditor->Width = '100%';
     $oFCKeditor->Height = '300';
     $oFCKeditor->Value = '  ';
     $this->view->fckeditor = $oFCKeditor;
     }6.在视图中显示"0" cellspacing="0" width=100%>
标题:'text' name='title'/>
内容:
$this->fckeditor->Create();
?>
7.Fckedotor 上传文件(file flash image media)调试

  • 打开/fckeditor/editor/filemanager/connectors/php/config.php找到:
$Config['Enabled'] = false
        改成:
        $Config['Enabled'] = true
        设置上传存放目录:
        找到:
        $Config['UserFilesPath'] = '/userfiles/'
        改成:
        $Config['UserFilesPath'] = '/uploads/' //此时文件路径在public下,这个文件夹得自己建!别忘了放一个.htaccess

  • 使用当前时间戳做为文件名
打开fckeditor/editor/filemanager/connectors/php/commands.php
找到
$sFileName = $oFile['name'] ;
改为
$sFileName = time().".".strtolower(array_pop(explode(".",$oFile['name'])));

  • 指定不同类型的文件上传到不同的目录中(图片在uploads/image/下,文件在uploads/file/下,flash在uploads/flash/下,视频在uploads/media/下)
打开fckeditor\editor\filemanager\connectors\php\config.php,重置以下项
  $Config['QuickUploadPath']['File']= $Config['UserFilesPath'] .'file/';
  $Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] .'image/' ;
  $Config['QuickUploadPath']['Flash'] = $Config['UserFilesPath'] .'flash/';
  $Config['QuickUploadPath']['Media'] = $Config['UserFilesPath'] .'media/';
8.备注
用$_POST['content']得到fckeditor的值。上传图片不能超过两兆!还有很多可以自定义,大多是修改fckconfig.js!
补充一下:上传目录和fck目录下都加个.htaccess文件

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

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP