用户
 找回密码
 入住 CI 中国社区
搜索
查看: 8952|回复: 14
收起左侧

[Web] CI集成FCKeditor

  [复制链接]
发表于 2010-8-15 23:00:07 | 显示全部楼层 |阅读模式
分享下CI集成FCKeditor
1、把FCKeditor复制到system/application/libraries/下
并建立一个FCKeditor.php的文件(继承FCKeditor的类)
代码如下:
PHP复制代码
 
<?php
                if ( ! defined('BASEPATH')) exit('No direct script access allowed');
        require_once('FCKeditor/fckeditor.php');
        /**
         * DK_FCKeditor extends FCKeditor
         * Author: Daker.W
         * Create Time: 2010/08/13
         **/

        class DK_FCKeditor extends FCKeditor
        {
                function DK_FCKeditor($config = array('InstanceName'=>''))
                {
                        $this->CI =& get_instance();
                       
                        if ( ! in_array('fckeditor_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
                        {
                                $this->CI->lang->load('fckeditor');
                        }
       
                        $this->local_time = time();
                        if (count($config) > 0)
                        {
                                $this->initialize($config);
                        }
                        parent::__construct($this->InstanceName);
                       
                        $this->BasePath         = $this->CI->config->item('fck_base_path');//配置文件中配置的FCK的路径
                        $this->ToolbarSet       = $this->CI->config->item('fck_toolbarset_default');//配置的默认样式
                       
                        log_message('debug', "FCKeditor Class Initialized");
                }
               
                function initialize($config = array())
                {
                        foreach ($config as $key => $val)
                        {
                                if (isset($this->$key))
                                {
                                        $this->$key = $val;
                                }
                        }
                }
        }//End Class
?>
 
复制代码

2.配置文件中增加两项配置
/**
* 配置fckeditor的路径
*/
$config['fck_base_path']                                                = $config['base_url']."libraries/FCKeditor/";
$config['fck_toolbarset_default']                                         = 'Default';


控制器重调用CODE:
PHP复制代码
 
<?php
 
class testfckeditor extends DK_Controller {
 
        function testfckeditor()
        {
                parent::DK_Controller();       
        }
       
        function index()
        {      
                $this->load->library('fckeditor', array('InstanceName' => 'content'));
                $this->load->library('smarty');
 
                $this->fckeditor->Width         = 600;
                $this->fckeditor->Height        = 600;
                $this->fckeditor->Value = '555555555';
                $sFCKeditor             = $this->fckeditor->CreateHtml();
                $this->smarty->assign('test',$sFCKeditor);
                $this->smarty->display('test/testsmarty.html');
        }
}
 
复制代码
发表于 2010-8-19 11:38:55 | 显示全部楼层
谢谢了!![
发表于 2010-8-19 14:43:29 | 显示全部楼层
我一般都是直接用JS引入的
发表于 2011-4-7 22:36:07 | 显示全部楼层
太复杂了,还是JS版吧。放之四海而皆准。
发表于 2011-4-22 11:37:38 | 显示全部楼层
是的 支持 JS
发表于 2011-4-23 15:15:11 | 显示全部楼层
这样有点麻烦,修改不是很方便呢。还是js好
发表于 2011-8-19 13:18:46 | 显示全部楼层
不错蛮详细的
发表于 2011-8-23 16:33:21 | 显示全部楼层
顶..........
发表于 2011-9-29 10:41:33 | 显示全部楼层
这个编辑器挺不错
发表于 2011-9-29 14:19:39 | 显示全部楼层
我也是这么做的。。。

本版积分规则