CodeIgniter(1.6.3)安装FCKeditor插件

来源:互联网 发布:php 加密解密函数 编辑:程序博客网 时间:2024/05/22 14:33

1. 下载解压FCKeditor 2.6.3,我是放在system/application/plugins/fckeditor/ 下。

2.根据你的php版本,将fckeditor_php4.php或fckeditor_php5.php复制到 /system/application/libraries/ 下,并更名为 fckeditor.php

3. 打开此文件,将类名更改为 Fckeditor,并修改你的构造器
 // PHP 5
    
function __construct( $instanceName )
     
{
        $this
->InstanceName    = $instanceName ;
        
$this->BasePath        = '/fckeditor/' ;
        
$this->Width        = '100%' ;
        
$this->Height        = '200' ;
        
$this->ToolbarSet    = 'Default' ;
        
$this->Value        = '' ;
        
$this->Config        = array() ;
    
}
// PHP 4
    
function Fckeditor( $instanceName )
    
{
        $this
->__construct( $instanceName ) ;
    
}


4. 打开 ./system/application/libraries/下的 fckeditor.php,复制FCKeditor_IsCompatibleBrowser()函数里的所有内容,替换到IsCompatible()函数里的所有内容

5. 修改 ./system/application/libraries/fckeditor.php 的 constructor 里的 basepath 定义


$this
->BasePath = base_url().'system/application/plugins/fckeditor/'  ;

6.如果你使用了.htaccess文件,需要做如下修改

RewriteCond $1 !^(index/.php|images|system/application/plugins/fckeditor)
7. 基本设置完毕,在控制器中调用:
        $this->load->library('fckeditor','content');
        $this->fckeditor->ToolbarSet = 'Basic';
        $data['fckeditor']=$this->fckeditor->CreateHtml();

    在view里用 <?=$fckeditor?>就可以了

8.如果要在一个页面显示多个fckeditor

$this->load->library('fckeditor', 'FCKEDITOR1');

$this->fckeditor->BasePath = 'system/plugins/FCKeditor/';
$this->fckeditor->ToolbarSet = 'Basic';

$data['fck1'] = $this->fckeditor->CreateHtml();
        
$this->fckeditor->InstanceName = 'FCKEDITOR2';
        
$data['fck2'] = $this->fckeditor->CreateHtml();

$this->load->view('mypage', $data);

在服务器端,可以这样:
$first_box = $this->input->post('FCKEDITOR1');
$second_box = $this->input->post('FCKEDITOR2');

其他的一些配置,你可以在fckconfig.js中自己修改

OK!生活就是这样美好。。


时代在发展,Codeigniter1.7.0安装新版本fck会遇到一些麻烦

CI 1.7.0安装FCKeditor2.6.x bug修复方法

如果你使用的是CodeIgniter1.7.0,常规方法可能会产生如下警告
1.
Severity: Warning
 
Message: Missing argument 1 for Fckeditor::__construct(), called in systemlibrariesLoader.php on line 931 and defined
 
Filename: libraries/fckeditor.php
 
Line Number: 130
 
2.
Severity: Notice
 
Message: Undefined variable: instanceName
 
Filename: libraries/fckeditor.php
 
Line Number: 132

解决办法:

1) 在控制器中,按照如下方法加载fckeditor,并传给其构造函数一个数组参数:
 
$this->load->library('fckeditor',array('instanceName' => 'content'));

2) 我使用的是PHP5,在fckeditor.php中,需要作如下修改:
function __construct( $array )
     {
        $this->InstanceName    = $array['instanceName'] ;
        .....
        .....
     }

接下来,就可以使用了
$content = $this->input->post('content');
(转自:http://blog.sina.com.cn/s/blog_4b93170a0100b1e4.html)

原创粉丝点击