xingch 发表于 2010-8-15 23:00:07

CI集成FCKeditor

分享下CI集成FCKeditor
1、把FCKeditor复制到system/application/libraries/下
并建立一个FCKeditor.php的文件(继承FCKeditor的类)
代码如下:

<?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

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');
        }
}

xiasix 发表于 2010-8-19 11:38:55

谢谢了!![

snllll 发表于 2010-8-19 14:43:29

我一般都是直接用JS引入的

smartweb 发表于 2011-4-7 22:36:07

太复杂了,还是JS版吧。放之四海而皆准。

litaobbs 发表于 2011-4-22 11:37:38

是的 支持 JS

tpopen 发表于 2011-4-23 15:15:11

这样有点麻烦,修改不是很方便呢。还是js好

365joomla 发表于 2011-8-19 13:18:46

不错蛮详细的

yeseason 发表于 2011-8-23 16:33:21

顶..........

NicholasWay 发表于 2011-9-29 10:41:33

这个编辑器挺不错

小蜗牛 发表于 2011-9-29 14:19:39

我也是这么做的。。。
页: [1] 2
查看完整版本: CI集成FCKeditor