|
分享下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');
}
}
复制代码 |
|